Skip to content

Commit c644918

Browse files
author
Unity Technologies
committed
Unity 2017.3.0a5 C# reference source code
1 parent 9bbee7b commit c644918

File tree

274 files changed

+10655
-9753
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+10655
-9753
lines changed

Editor/Mono/2D/SpriteAtlas/SpriteAtlasInspector.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ class Styles
5353
public readonly GUIContent bindAsDefaultLabel = EditorGUIUtility.TextContent("Include in Build|Packed textures will be included in the build by default.");
5454
public readonly GUIContent enableRotationLabel = EditorGUIUtility.TextContent("Allow Rotation|Try rotating the sprite to fit better during packing.");
5555
public readonly GUIContent enableTightPackingLabel = EditorGUIUtility.TextContent("Tight Packing|Use the mesh outline to fit instead of the whole texture rect during packing.");
56+
public readonly GUIContent paddingLabel = EditorGUIUtility.TextContent("Padding|The amount of extra padding between packed sprites.");
5657

5758
public readonly GUIContent generateMipMapLabel = EditorGUIUtility.TextContent("Generate Mip Maps");
59+
public readonly GUIContent sRGBLabel = EditorGUIUtility.TextContent("sRGB|Texture content is stored in gamma space.");
5860
public readonly GUIContent readWrite = EditorGUIUtility.TextContent("Read/Write Enabled|Enable to be able to access the raw pixel data from code.");
5961
public readonly GUIContent variantMultiplierLabel = EditorGUIUtility.TextContent("Scale|Down scale ratio.");
6062
public readonly GUIContent copyMasterButton = EditorGUIUtility.TextContent("Copy Master's Settings|Copy all master's settings into this variant.");
@@ -77,10 +79,17 @@ class Styles
7779
EditorGUIUtility.TextContent("Variant"),
7880
};
7981

82+
public readonly int[] paddingValues = { 2, 4, 8 };
83+
public readonly GUIContent[] paddingOptions;
84+
8085
public Styles()
8186
{
8287
dropzoneStyle.alignment = TextAnchor.MiddleCenter;
8388
dropzoneStyle.border = new RectOffset(10, 10, 10, 10);
89+
90+
paddingOptions = new GUIContent[paddingValues.Length];
91+
for (var i = 0; i < paddingValues.Length; ++i)
92+
paddingOptions[i] = EditorGUIUtility.TextContent(paddingValues[i].ToString());
8493
}
8594
}
8695

@@ -98,8 +107,10 @@ private enum AtlasType { Undefined = -1, Master = 0, Variant = 1 }
98107
private SerializedProperty m_AnisoLevel;
99108
private SerializedProperty m_GenerateMipMaps;
100109
private SerializedProperty m_Readable;
110+
private SerializedProperty m_UseSRGB;
101111
private SerializedProperty m_EnableTightPacking;
102112
private SerializedProperty m_EnableRotation;
113+
private SerializedProperty m_Padding;
103114
private SerializedProperty m_BindAsDefault;
104115
private SerializedProperty m_Packables;
105116

@@ -171,9 +182,11 @@ void OnEnable()
171182
m_AnisoLevel = serializedObject.FindProperty("m_EditorData.textureSettings.anisoLevel");
172183
m_GenerateMipMaps = serializedObject.FindProperty("m_EditorData.textureSettings.generateMipMaps");
173184
m_Readable = serializedObject.FindProperty("m_EditorData.textureSettings.readable");
185+
m_UseSRGB = serializedObject.FindProperty("m_EditorData.textureSettings.sRGB");
174186

175187
m_EnableTightPacking = serializedObject.FindProperty("m_EditorData.packingParameters.enableTightPacking");
176188
m_EnableRotation = serializedObject.FindProperty("m_EditorData.packingParameters.enableRotation");
189+
m_Padding = serializedObject.FindProperty("m_EditorData.packingParameters.padding");
177190

178191
m_Hash = serializedObject.FindProperty("m_EditorData.hashString").stringValue;
179192
m_MasterAtlas = serializedObject.FindProperty("m_MasterAtlas");
@@ -389,6 +402,7 @@ private void HandleMasterSettingUI()
389402

390403
HandleBoolToIntPropertyField(m_EnableRotation, s_Styles.enableRotationLabel);
391404
HandleBoolToIntPropertyField(m_EnableTightPacking, s_Styles.enableTightPackingLabel);
405+
EditorGUILayout.IntPopup(m_Padding, s_Styles.paddingOptions, s_Styles.paddingValues, s_Styles.paddingLabel);
392406

393407
GUILayout.Space(EditorGUI.kSpacing);
394408
}
@@ -399,6 +413,7 @@ private void HandleTextureSettingUI()
399413

400414
HandleBoolToIntPropertyField(m_Readable, s_Styles.readWrite);
401415
HandleBoolToIntPropertyField(m_GenerateMipMaps, s_Styles.generateMipMapLabel);
416+
HandleBoolToIntPropertyField(m_UseSRGB, s_Styles.sRGBLabel);
402417
EditorGUILayout.PropertyField(m_FilterMode);
403418

404419
var showAniso = !m_FilterMode.hasMultipleDifferentValues && !m_GenerateMipMaps.hasMultipleDifferentValues

Editor/Mono/Animation/AnimationWindow/AnimationContextualPropertyMenu.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,25 @@ void OnPropertyContextMenu(GenericMenu menu, SerializedProperty property)
6060
}
6161
}
6262

63-
void OnPropertyContextMenu(GenericMenu menu, MaterialProperty property, Renderer targetObject)
63+
void OnPropertyContextMenu(GenericMenu menu, MaterialProperty property, Renderer[] renderers)
6464
{
6565
if (m_Responder == null)
6666
return;
6767

6868
if (property.targets == null || property.targets.Length == 0)
6969
return;
7070

71-
PropertyModification[] modifications = MaterialAnimationUtility.MaterialPropertyToPropertyModifications(property, targetObject);
72-
if (m_Responder.IsEditable(targetObject))
73-
OnPropertyContextMenu(menu, modifications);
71+
if (renderers == null || renderers.Length == 0)
72+
return;
73+
74+
var modifications = new List<PropertyModification>();
75+
foreach (Renderer renderer in renderers)
76+
{
77+
modifications.AddRange(MaterialAnimationUtility.MaterialPropertyToPropertyModifications(property, renderer));
78+
}
79+
80+
if (m_Responder.IsEditable(renderers[0]))
81+
OnPropertyContextMenu(menu, modifications.ToArray());
7482
else
7583
OnDisabledPropertyContextMenu(menu);
7684
}

Editor/Mono/Animation/AnimationWindow/AnimationWindowClipPopup.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,21 @@ private string[] GetClipMenuContent()
6969
return content.ToArray();
7070
}
7171

72-
private string[] GetClipNames()
72+
private AnimationClip[] GetOrderedClipList()
7373
{
74-
string[] clipNames;
75-
7674
AnimationClip[] clips = new AnimationClip[0];
77-
if (state.activeRootGameObject != null && state.activeAnimationClip != null)
75+
if (state.activeRootGameObject != null)
7876
clips = AnimationUtility.GetAnimationClips(state.activeRootGameObject);
7977

80-
clipNames = new string[clips.Length];
78+
Array.Sort(clips, (AnimationClip clip1, AnimationClip clip2) => CurveUtility.GetClipName(clip1).CompareTo(CurveUtility.GetClipName(clip2)));
79+
80+
return clips;
81+
}
82+
83+
private string[] GetClipNames()
84+
{
85+
AnimationClip[] clips = GetOrderedClipList();
86+
string[] clipNames = new string[clips.Length];
8187

8288
for (int i = 0; i < clips.Length; i++)
8389
clipNames[i] = CurveUtility.GetClipName(clips[i]);
@@ -90,9 +96,9 @@ private AnimationClip IndexToClip(int index)
9096
{
9197
if (state.activeRootGameObject != null)
9298
{
93-
AnimationClip[] clips = AnimationUtility.GetAnimationClips(state.activeRootGameObject);
99+
AnimationClip[] clips = GetOrderedClipList();
94100
if (index >= 0 && index < clips.Length)
95-
return AnimationUtility.GetAnimationClips(state.activeRootGameObject)[index];
101+
return clips[index];
96102
}
97103

98104
return null;
@@ -104,7 +110,8 @@ private int ClipToIndex(AnimationClip clip)
104110
if (state.activeRootGameObject != null)
105111
{
106112
int index = 0;
107-
foreach (AnimationClip other in AnimationUtility.GetAnimationClips(state.activeRootGameObject))
113+
AnimationClip[] clips = GetOrderedClipList();
114+
foreach (AnimationClip other in clips)
108115
{
109116
if (clip == other)
110117
return index;

Editor/Mono/Animation/MecanimUtilities.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public static bool StateMachineRelativePath(AnimatorStateMachine parent, Animato
1919
hierarchy.Add(parent);
2020
if (parent == toFind)
2121
return true;
22-
23-
for (int i = 0; i < parent.stateMachines.Length; i++)
22+
var childStateMachines = AnimatorStateMachine.StateMachineCache.GetChildStateMachines(parent);
23+
for (int i = 0; i < childStateMachines.Length; i++)
2424
{
25-
if (StateMachineRelativePath(parent.stateMachines[i].stateMachine, toFind, ref hierarchy))
25+
if (StateMachineRelativePath(childStateMachines[i].stateMachine, toFind, ref hierarchy))
2626
return true;
2727
}
2828
hierarchy.Remove(parent);

Editor/Mono/Animation/StateMachine.cs

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,39 @@ public partial class AnimatorStateMachine : Object
232232
private PushUndoIfNeeded undoHandler = new PushUndoIfNeeded(true);
233233
internal bool pushUndo { set { undoHandler.pushUndo = value; } }
234234

235+
internal class StateMachineCache
236+
{
237+
static Dictionary<AnimatorStateMachine, ChildAnimatorStateMachine[]> m_ChildStateMachines;
238+
static bool m_Initialized;
239+
240+
static void Init()
241+
{
242+
if (!m_Initialized)
243+
{
244+
m_ChildStateMachines = new Dictionary<AnimatorStateMachine, ChildAnimatorStateMachine[]>();
245+
m_Initialized = true;
246+
}
247+
}
248+
249+
static public void Clear()
250+
{
251+
Init();
252+
m_ChildStateMachines.Clear();
253+
}
254+
255+
static public ChildAnimatorStateMachine[] GetChildStateMachines(AnimatorStateMachine parent)
256+
{
257+
Init();
235258

259+
ChildAnimatorStateMachine[] children;
260+
if (m_ChildStateMachines.TryGetValue(parent, out children) == false)
261+
{
262+
children = parent.stateMachines;
263+
m_ChildStateMachines.Add(parent, children);
264+
}
265+
return children;
266+
}
267+
}
236268
internal List<ChildAnimatorState> statesRecursive
237269
{
238270
get
@@ -253,11 +285,12 @@ internal List<ChildAnimatorStateMachine> stateMachinesRecursive
253285
get
254286
{
255287
List<ChildAnimatorStateMachine> ret = new List<ChildAnimatorStateMachine>();
256-
ret.AddRange(stateMachines);
288+
var childStateMachines = AnimatorStateMachine.StateMachineCache.GetChildStateMachines(this);
289+
ret.AddRange(childStateMachines);
257290

258-
for (int j = 0; j < stateMachines.Length; j++)
291+
for (int j = 0; j < childStateMachines.Length; j++)
259292
{
260-
ret.AddRange(stateMachines[j].stateMachine.stateMachinesRecursive);
293+
ret.AddRange(childStateMachines[j].stateMachine.stateMachinesRecursive);
261294
}
262295
return ret;
263296
}
@@ -636,10 +669,11 @@ internal AnimatorStateMachine FindStateMachine(string path)
636669
// first element is always Root statemachine 'this'
637670
AnimatorStateMachine currentSM = this;
638671
// last element is state name, we don't care
672+
var childStateMachines = AnimatorStateMachine.StateMachineCache.GetChildStateMachines(currentSM);
639673
for (int i = 1; i < smNames.Length - 1 && currentSM != null; ++i)
640674
{
641-
int index = System.Array.FindIndex(currentSM.stateMachines, t => t.stateMachine.name == smNames[i]);
642-
currentSM = index >= 0 ? currentSM.stateMachines[index].stateMachine : null;
675+
int index = System.Array.FindIndex(childStateMachines, t => t.stateMachine.name == smNames[i]);
676+
currentSM = index >= 0 ? childStateMachines[index].stateMachine : null;
643677
}
644678

645679
return (currentSM == null) ? this : currentSM;

Editor/Mono/AssetPipeline/LocalCacheServer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ public static bool PingHost(string host, int port, int timeout)
109109

110110
public static bool WaitForServerToComeAlive(int port)
111111
{
112-
for (int i = 0; i < 500; i++)
112+
DateTime start = DateTime.Now;
113+
DateTime maximum = start.AddSeconds(5);
114+
while (DateTime.Now < maximum)
113115
{
114116
if (PingHost("localhost", port, 10))
115117
{
116-
System.Console.WriteLine("Server Came alive after " + (i * 10) + "ms");
118+
System.Console.WriteLine("Server Came alive after {0} ms", (DateTime.Now - start).TotalMilliseconds);
117119
return true;
118120
}
119121
}

Editor/Mono/AssetPipeline/ModelImporter.bindings.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ public enum ModelImporterMeshCompression
262262
High = 3,
263263
}
264264

265+
public enum ModelImporterIndexFormat
266+
{
267+
Auto = 0,
268+
UInt16 = 1,
269+
UInt32 = 2,
270+
}
271+
265272
[NativeType(Header = "Editor/Src/AssetPipeline/ModelImporting/ModelImporter.h")]
266273
public enum ModelImporterAnimationCompression
267274
{
@@ -480,6 +487,12 @@ public extern bool keepQuads
480487
set;
481488
}
482489

490+
public extern ModelImporterIndexFormat indexFormat
491+
{
492+
get;
493+
set;
494+
}
495+
483496
public extern bool preserveHierarchy
484497
{
485498
get;

0 commit comments

Comments
 (0)