Skip to content

Commit 0c33b10

Browse files
author
Unity Technologies
committed
Unity 2017.2.0a2 C# reference source code
1 parent 9be0e82 commit 0c33b10

File tree

139 files changed

+2511
-2867
lines changed

Some content is hidden

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

139 files changed

+2511
-2867
lines changed

Editor/Mono/Animation/AnimationWindow/AnimationWindowUtility.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,15 @@ public static AnimationWindowKeyframe AddKeyframeToCurve(AnimationWindowCurve cu
206206
int keyIndex = animationCurve.AddKey(tempKey);
207207
if (keyIndex != -1)
208208
{
209+
// Make sure tangent slopes default to ClampedAuto. Tangent mode will be modified afterwards.
210+
AnimationUtility.SetKeyLeftTangentMode(animationCurve, keyIndex, TangentMode.ClampedAuto);
211+
AnimationUtility.SetKeyRightTangentMode(animationCurve, keyIndex, TangentMode.ClampedAuto);
212+
AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyIndex);
213+
209214
CurveUtility.SetKeyModeFromContext(animationCurve, keyIndex);
210215
keyframe.m_TangentMode = animationCurve[keyIndex].tangentMode;
216+
keyframe.m_InTangent = animationCurve[keyIndex].inTangent;
217+
keyframe.m_OutTangent = animationCurve[keyIndex].outTangent;
211218
}
212219
}
213220

Editor/Mono/Animation/AnimationWindow/Deprecated/UtilityClasses.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ public static void SetKeyModeFromContext(AnimationCurve curve, int keyIndex)
8181
{
8282
if (AnimationUtility.GetKeyBroken(curve[keyIndex - 1]))
8383
broken = true;
84-
if (AnimationUtility.GetKeyRightTangentMode(curve[keyIndex - 1]) == TangentMode.ClampedAuto)
84+
TangentMode prevTangentMode = AnimationUtility.GetKeyRightTangentMode(curve[keyIndex - 1]);
85+
if (prevTangentMode == TangentMode.ClampedAuto || prevTangentMode == TangentMode.Auto)
8586
smoothTangent = true;
8687
}
8788
if (keyIndex < curve.length - 1)
8889
{
8990
if (AnimationUtility.GetKeyBroken(curve[keyIndex + 1]))
9091
broken = true;
91-
if (AnimationUtility.GetKeyLeftTangentMode(curve[keyIndex + 1]) == TangentMode.ClampedAuto)
92+
TangentMode nextTangentMode = AnimationUtility.GetKeyLeftTangentMode(curve[keyIndex + 1]);
93+
if (nextTangentMode == TangentMode.ClampedAuto || nextTangentMode == TangentMode.Auto)
9294
smoothTangent = true;
9395
}
9496

Editor/Mono/Animation/StateMachine.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,18 @@ public AnimatorState AddState(string name, Vector3 position)
351351

352352
public void AddState(AnimatorState state, Vector3 position)
353353
{
354+
ChildAnimatorState[] childStates = states;
355+
if (System.Array.Exists(childStates, childState => childState.state == state))
356+
{
357+
Debug.LogWarning(System.String.Format("State '{0}' already exists in state machine '{1}', discarding new state.", state.name, name));
358+
return;
359+
}
360+
354361
undoHandler.DoUndo(this, "State added");
355362
ChildAnimatorState newState = new ChildAnimatorState();
356363
newState.state = state;
357364
newState.position = position;
358-
ChildAnimatorState[] childStates = states;
365+
359366
ArrayUtility.Add(ref childStates, newState);
360367
states = childStates;
361368
}
@@ -388,12 +395,18 @@ public AnimatorStateMachine AddStateMachine(string name, Vector3 position)
388395

389396
public void AddStateMachine(AnimatorStateMachine stateMachine, Vector3 position)
390397
{
398+
ChildAnimatorStateMachine[] childStateMachines = stateMachines;
399+
if (System.Array.Exists(childStateMachines, childStateMachine => childStateMachine.stateMachine == stateMachine))
400+
{
401+
Debug.LogWarning(System.String.Format("Sub state machine '{0}' already exists in state machine '{1}', discarding new state machine.", stateMachine.name, name));
402+
return;
403+
}
404+
391405
undoHandler.DoUndo(this, "StateMachine " + stateMachine.name + " added");
392406
ChildAnimatorStateMachine newStateMachine = new ChildAnimatorStateMachine();
393407
newStateMachine.stateMachine = stateMachine;
394408
newStateMachine.position = position;
395409

396-
ChildAnimatorStateMachine[] childStateMachines = stateMachines;
397410
ArrayUtility.Add(ref childStateMachines, newStateMachine);
398411
stateMachines = childStateMachines;
399412
}

Editor/Mono/Annotation/SceneFXWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public SceneFXWindow(SceneView sceneView)
3434

3535
public override void OnGUI(Rect rect)
3636
{
37-
if (m_SceneView == null || m_SceneView.m_SceneViewState == null)
37+
if (m_SceneView == null || m_SceneView.sceneViewState == null)
3838
return;
3939

4040
// We do not use the layout event
@@ -61,12 +61,12 @@ public override void OnGUI(Rect rect)
6161

6262
private void Draw(Rect rect)
6363
{
64-
if (m_SceneView == null || m_SceneView.m_SceneViewState == null)
64+
if (m_SceneView == null || m_SceneView.sceneViewState == null)
6565
return;
6666

6767
var drawPos = new Rect(kFrameWidth, kFrameWidth, rect.width - 2 * kFrameWidth, EditorGUI.kSingleLineHeight);
6868

69-
var state = m_SceneView.m_SceneViewState;
69+
var state = m_SceneView.sceneViewState;
7070

7171
//
7272
// scene view effect options

Editor/Mono/Annotation/SceneRenderModeWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public override void OnOpen()
213213

214214
public override void OnGUI(Rect rect)
215215
{
216-
if (m_SceneView == null || m_SceneView.m_SceneViewState == null)
216+
if (m_SceneView == null || m_SceneView.sceneViewState == null)
217217
return;
218218

219219
// We do not use the layout event

Editor/Mono/AssemblyHelper.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ static private void AddReferencedAssembliesRecurse(string assemblyPath, List<str
134134

135135
if (foundPath == "")
136136
{
137+
if (!BuildPipeline.IsFeatureSupported("ENABLE_MODULAR_UNITYENGINE_ASSEMBLIES", target))
138+
{
139+
// Skip module dlls if the platform is not set up for a modular UnityEngine.
140+
if (IsUnityEngineModule(referencedAssembly.Name))
141+
continue;
142+
}
143+
137144
// Ignore architecture specific plugin references
138145
var found = false;
139146
foreach (var extension in new[] { ".dll", ".winmd" })
@@ -201,6 +208,11 @@ static public string[] FindAssembliesReferencedBy(string path, string[] foldersT
201208
return FindAssembliesReferencedBy(tmp, foldersToSearch, target);
202209
}
203210

211+
static public bool IsUnityEngineModule(string assemblyName)
212+
{
213+
return assemblyName.EndsWith("Module") && assemblyName.StartsWith("UnityEngine.");
214+
}
215+
204216
private static bool IsTypeAUserExtendedScript(AssemblyDefinition assembly, TypeReference type)
205217
{
206218
if (type == null)

Editor/Mono/AssetModificationProcessor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ internal static bool IsOpenForEdit(string assetPath, out string message, StatusQ
274274
if (String.IsNullOrEmpty(assetPath))
275275
return true; // assetPath can be empty in some cases where Unity is checking for stuff in Library folder
276276

277+
if (AssetDatabase.IsPackagedAssetPath(assetPath))
278+
{
279+
return false;
280+
}
281+
277282
bool finalResult = AssetModificationHook.IsOpenForEdit(assetPath, out message, statusOptions);
278283

279284
foreach (var method in GetIsOpenForEditMethods())
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using System;
6+
using UnityEngine;
7+
using UnityEngine.Bindings;
8+
9+
namespace UnityEditor
10+
{
11+
[NativeType(Header = "Editor/Mono/Audio/WaveformStreamer.bindings.h")]
12+
internal sealed partial class WaveformStreamer
13+
{
14+
internal IntPtr m_Data;
15+
16+
public bool done
17+
{
18+
get { return Internal_WaveformStreamerQueryFinishedStatus(m_Data); }
19+
}
20+
public void Stop()
21+
{
22+
Internal_WaveformStreamerStop(m_Data);
23+
}
24+
25+
public WaveformStreamer(AudioClip clip, double start, double duration,
26+
int numOutputSamples, Func<WaveformStreamer, float[], int, bool> onNewWaveformData)
27+
{
28+
m_Data = Internal_WaveformStreamerCreate(this, clip, start, duration, numOutputSamples, onNewWaveformData);
29+
}
30+
31+
private WaveformStreamer(AudioClip clip, double start, double duration,
32+
int numOutputSamples, Func<object, float[], int, bool> onNewWaveformData)
33+
{
34+
m_Data = Internal_WaveformStreamerCreateUntyped(this, clip, start, duration, numOutputSamples, onNewWaveformData);
35+
}
36+
37+
~WaveformStreamer()
38+
{
39+
if (m_Data != IntPtr.Zero)
40+
Internal_WaveformStreamerDestroy(m_Data);
41+
}
42+
43+
internal static object CreateUntypedWaveformStreamer(AudioClip clip, double start, double duration,
44+
int numOutputSamples, Func<object, float[], int, bool> onNewWaveformData)
45+
{
46+
return new WaveformStreamer(clip, start, duration, numOutputSamples, onNewWaveformData);
47+
}
48+
49+
[NativeThrows]
50+
internal static extern IntPtr Internal_WaveformStreamerCreate(WaveformStreamer instance, [NotNull] AudioClip clip, double start, double duration,
51+
int numOutputSamples, [NotNull] Func<WaveformStreamer, float[], int, bool> onNewWaveformData);
52+
53+
internal static extern bool Internal_WaveformStreamerQueryFinishedStatus(IntPtr streamer);
54+
55+
internal static extern void Internal_WaveformStreamerStop(IntPtr streamer);
56+
57+
[NativeThrows]
58+
internal static extern IntPtr Internal_WaveformStreamerCreateUntyped(object instance, [NotNull] AudioClip clip, double start, double duration,
59+
int numOutputSamples, [NotNull] Func<object, float[], int, bool> onNewWaveformData);
60+
61+
[NativeMethod(IsThreadSafe = true)]
62+
internal static extern void Internal_WaveformStreamerDestroy(IntPtr streamer);
63+
}
64+
}

Editor/Mono/BuildPipeline/AssemblyStripper.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private static void RunAssemblyStripper(string stagingAreaData, IEnumerable asse
164164
if (rcr != null)
165165
{
166166
blacklists = blacklists.Concat(new[] {
167-
WriteMethodsToPreserveBlackList(stagingAreaData, rcr),
167+
WriteMethodsToPreserveBlackList(stagingAreaData, rcr, platformProvider.target),
168168
MonoAssemblyStripping.GenerateLinkXmlToPreserveDerivedTypes(stagingAreaData, managedAssemblyFolderPath, rcr)
169169
});
170170
}
@@ -259,23 +259,28 @@ private static void RunAssemblyStripper(string stagingAreaData, IEnumerable asse
259259
Directory.Delete(tempStripPath);
260260
}
261261

262-
private static string WriteMethodsToPreserveBlackList(string stagingAreaData, RuntimeClassRegistry rcr)
262+
private static string WriteMethodsToPreserveBlackList(string stagingAreaData, RuntimeClassRegistry rcr, BuildTarget target)
263263
{
264264
var methodPerserveBlackList = Path.IsPathRooted(stagingAreaData) ? "" : Directory.GetCurrentDirectory() + "/";
265265
methodPerserveBlackList += stagingAreaData + "/methods_pointedto_by_uievents.xml";
266-
File.WriteAllText(methodPerserveBlackList, GetMethodPreserveBlacklistContents(rcr));
266+
File.WriteAllText(methodPerserveBlackList, GetMethodPreserveBlacklistContents(rcr, target));
267267
return methodPerserveBlackList;
268268
}
269269

270-
private static string GetMethodPreserveBlacklistContents(RuntimeClassRegistry rcr)
270+
private static string GetMethodPreserveBlacklistContents(RuntimeClassRegistry rcr, BuildTarget target)
271271
{
272272
var sb = new StringBuilder();
273273
sb.AppendLine("<linker>");
274274

275275
var groupedByAssembly = rcr.GetMethodsToPreserve().GroupBy(m => m.assembly);
276276
foreach (var assembly in groupedByAssembly)
277277
{
278-
sb.AppendLine(string.Format("\t<assembly fullname=\"{0}\">", assembly.Key));
278+
var assemblyName = assembly.Key;
279+
// Convert assembly names to monolithic Unity Engine if target platform requires it.
280+
if (AssemblyHelper.IsUnityEngineModule(assemblyName) && !BuildPipeline.IsFeatureSupported("ENABLE_MODULAR_UNITYENGINE_ASSEMBLIES", target))
281+
sb.AppendLine(string.Format("\t<assembly fullname=\"{0}\">", "UnityEngine"));
282+
else
283+
sb.AppendLine(string.Format("\t<assembly fullname=\"{0}\">", assemblyName));
279284
var groupedByType = assembly.GroupBy(m => m.fullTypeName);
280285
foreach (var type in groupedByType)
281286
{

Editor/Mono/BuildPipeline/MonoAssemblyStripping.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ public static AssemblyDefinition ResolveAssemblyReference(IAssemblyResolver reso
269269
}
270270
catch (AssemblyResolutionException e)
271271
{
272+
// Skip module dlls if we can't find them - we might build for a platform without modular UnityEngine support.
273+
if (AssemblyHelper.IsUnityEngineModule(assemblyName.Name))
274+
return null;
275+
272276
// DefaultAssemblyResolver doesn't handle windows runtime references correctly. But that is okay, as they cannot derive from managed types anyway
273277
if (e.AssemblyReference.IsWindowsRuntime)
274278
return null;

0 commit comments

Comments
 (0)