Skip to content

Commit eb33413

Browse files
author
Unity Technologies
committed
Unity 2019.1.0a13 C# reference source code
1 parent bec1fad commit eb33413

File tree

364 files changed

+4555
-1713
lines changed

Some content is hidden

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

364 files changed

+4555
-1713
lines changed

Editor/Mono/Animation/AnimationMode.bindings.cs

+7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public class AnimationMode
3737
static private bool s_InAnimationPlaybackMode = false;
3838
static private bool s_InAnimationRecordMode = false;
3939

40+
static internal event Action onAnimationRecordingStart;
41+
static internal event Action onAnimationRecordingStop;
42+
4043
static private PrefColor s_AnimatedPropertyColor = new PrefColor("Animation/Property Animated", 0.82f, 0.97f, 1.00f, 1.00f, 0.54f, 0.85f, 1.00f, 1.00f);
4144
static private PrefColor s_RecordedPropertyColor = new PrefColor("Animation/Property Recorded", 1.00f, 0.60f, 0.60f, 1.00f, 1.00f, 0.50f, 0.50f, 1.00f);
4245
static private PrefColor s_CandidatePropertyColor = new PrefColor("Animation/Property Candidate", 1.00f, 0.70f, 0.60f, 1.00f, 1.00f, 0.67f, 0.43f, 1.00f);
@@ -110,6 +113,8 @@ internal static void StartAnimationPlaybackMode()
110113
internal static void StopAnimationRecording()
111114
{
112115
s_InAnimationRecordMode = false;
116+
117+
onAnimationRecordingStop?.Invoke();
113118
}
114119

115120
internal static bool InAnimationRecording()
@@ -120,6 +125,8 @@ internal static bool InAnimationRecording()
120125
internal static void StartAnimationRecording()
121126
{
122127
s_InAnimationRecordMode = true;
128+
129+
onAnimationRecordingStart?.Invoke();
123130
}
124131

125132
[NativeThrows]

Editor/Mono/Animation/AnimationWindow/AnimationWindowControl.cs

+12-8
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ private static bool HasFlag(ResampleFlags flags, ResampleFlags flag)
128128
private IAnimationWindowPostProcess[] m_PostProcessComponents;
129129
private PlayableGraph m_Graph;
130130
private Playable m_GraphRoot;
131+
private AnimationClipPlayable m_ClipPlayable;
132+
private AnimationClipPlayable m_CandidateClipPlayable;
131133

132134
private static ProfilerMarker s_ResampleAnimationMarker = new ProfilerMarker("AnimationWindowControl.ResampleAnimation");
133135

@@ -506,7 +508,7 @@ private void DestroyGraph()
506508
return;
507509

508510
m_Graph.Destroy();
509-
m_GraphRoot.Destroy();
511+
m_GraphRoot = Playable.Null;
510512
}
511513

512514
private void RebuildGraph(Animator animator)
@@ -516,21 +518,21 @@ private void RebuildGraph(Animator animator)
516518
m_Graph = PlayableGraph.Create("PreviewGraph");
517519
m_Graph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
518520

519-
var clipPlayable = AnimationClipPlayable.Create(m_Graph, state.activeAnimationClip);
520-
clipPlayable.SetOverrideLoopTime(true);
521-
clipPlayable.SetLoopTime(false);
522-
clipPlayable.SetApplyFootIK(false);
521+
m_ClipPlayable = AnimationClipPlayable.Create(m_Graph, state.activeAnimationClip);
522+
m_ClipPlayable.SetOverrideLoopTime(true);
523+
m_ClipPlayable.SetLoopTime(false);
524+
m_ClipPlayable.SetApplyFootIK(false);
523525

524-
m_GraphRoot = (Playable)clipPlayable;
526+
m_GraphRoot = (Playable)m_ClipPlayable;
525527

526528
if (m_CandidateClip != null)
527529
{
528530
var mixer = AnimationLayerMixerPlayable.Create(m_Graph, 2);
529531

530-
var candidateClipPlayable = AnimationClipPlayable.Create(m_Graph, m_CandidateClip);
532+
m_CandidateClipPlayable = AnimationClipPlayable.Create(m_Graph, m_CandidateClip);
531533

532534
m_Graph.Connect(m_GraphRoot, 0, mixer, 0);
533-
m_Graph.Connect(candidateClipPlayable, 0, mixer, 1);
535+
m_Graph.Connect(m_CandidateClipPlayable, 0, mixer, 1);
534536

535537
mixer.SetInputWeight(0, 1.0f);
536538
mixer.SetInputWeight(1, 1.0f);
@@ -605,6 +607,8 @@ private void ResampleAnimation(ResampleFlags flags)
605607
if (m_CandidateClip != null)
606608
AnimationMode.AddCandidates(state.activeRootGameObject, m_CandidateClip);
607609

610+
m_ClipPlayable.SetSampleRate(playing ? -1 : state.activeAnimationClip.frameRate);
611+
608612
AnimationMode.SamplePlayableGraph(state.activeRootGameObject, m_Graph, 0, time.time);
609613

610614
// This will cover euler/quaternion matching in basic playable graphs only (animation clip + candidate clip).

Editor/Mono/AssetStore/AssetStoreWindow.cs

+13
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,19 @@ public void Refresh()
193193
webView.Show();
194194
}
195195

196+
public void OnAddedAsTab()
197+
{
198+
// Make sure the parent window is set correctly for CEF if this instance is being moved from a different DockArea.
199+
SetFocus(true);
200+
}
201+
202+
public void OnBeforeRemovedAsTab()
203+
{
204+
// Set the CEF parent window as if the tab were becoming invisible prior to tab removal. This will keep CEF from cleaning up the AssetStoreWindow browser
205+
// window if the AssetStoreWindow is being dragged to a new DockArea and was the last tab in it's old DockArea.
206+
OnBecameInvisible();
207+
}
208+
196209
protected virtual void OnGotFocus()
197210
{
198211
m_GotFocus = true;

Editor/Mono/Audio/Mixer/AudioMixerDescription.cs

+2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public static void Refresh()
6161
ClearDefinitions();
6262

6363
RegisterAudioMixerEffect("Attenuation", new MixerParameterDefinition[0]);
64+
6465
RegisterAudioMixerEffect("Send", new MixerParameterDefinition[0]);
66+
6567
RegisterAudioMixerEffect("Receive", new MixerParameterDefinition[0]);
6668

6769
var duckVolDef = new MixerParameterDefinition[7];

Editor/Mono/Audio/Mixer/Bindings/AudioMixerController.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public override string ResolveStringPath(bool getOnlyBasePath)
4545
{
4646
return "Pitch" + GetBasePath(group.GetDisplayString(), null);
4747
}
48+
else if (group.GetGUIDForSend() == parameter)
49+
{
50+
return "Send" + GetBasePath(group.GetDisplayString(), null);
51+
}
4852
else
4953
{
5054
return "Error finding Parameter path.";
@@ -218,7 +222,8 @@ public string ResolveExposedParameterPath(GUID parameter, bool getOnlyBasePath)
218222
foreach (AudioMixerGroupController group in groups)
219223
{
220224
if (group.GetGUIDForVolume() == parameter ||
221-
group.GetGUIDForPitch() == parameter)
225+
group.GetGUIDForPitch() == parameter ||
226+
group.GetGUIDForSend() == parameter)
222227
{
223228
AudioGroupParameterPath newPath = new AudioGroupParameterPath(group, parameter);
224229
exposedParamCache[parameter] = newPath;
@@ -362,7 +367,7 @@ private void DestroyExposedParametersContainedInGroup(AudioMixerGroupController
362367
var exposedParams = exposedParameters;
363368
foreach (var param in exposedParams)
364369
{
365-
if (group.GetGUIDForVolume() == param.guid || group.GetGUIDForPitch() == param.guid)
370+
if (group.GetGUIDForVolume() == param.guid || group.GetGUIDForPitch() == param.guid || group.GetGUIDForSend() == param.guid)
366371
RemoveExposedParameter(param.guid);
367372
}
368373
}
@@ -595,6 +600,8 @@ private AudioMixerGroupController DuplicateGroupRecurse(AudioMixerGroupControlle
595600
s.SetValue(targetGroup.GetGUIDForVolume(), value);
596601
if (s.GetValue(sourceGroup.GetGUIDForPitch(), out value))
597602
s.SetValue(targetGroup.GetGUIDForPitch(), value);
603+
if (s.GetValue(sourceGroup.GetGUIDForSend(), out value))
604+
s.SetValue(targetGroup.GetGUIDForSend(), value);
598605
}
599606

600607
AssetDatabase.AddObjectToAsset(targetGroup, this);

Editor/Mono/Audio/Mixer/GUI/AudioMixerEffectView.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ public void DoEffectGUI(int effectIndex, AudioMixerGroupController group, List<A
283283

284284
if (effect.sendTarget != null)
285285
{
286-
float wetLevel = effect.GetValueForMixLevel(controller, controller.TargetSnapshot);
287-
if (AudioMixerEffectGUI.Slider(Texts.sendLevel, ref wetLevel, 1.0f, 1.0f, Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioEffectParameterPath(group, effect, effect.GetGUIDForMixLevel())))
286+
float wetLevel = group.GetValueForSend(controller, controller.TargetSnapshot);
287+
if (AudioMixerEffectGUI.Slider(Texts.sendLevel, ref wetLevel, 1.0f, 1.0f, Texts.dB, AudioMixerController.kMinVolume, AudioMixerController.kMaxEffect, controller, new AudioGroupParameterPath(group, group.GetGUIDForSend())))
288288
{
289289
Undo.RecordObject(controller.TargetSnapshot, "Change Send Level");
290-
effect.SetValueForMixLevel(controller, controller.TargetSnapshot, wetLevel);
290+
group.SetValueForSend(controller, controller.TargetSnapshot, wetLevel);
291291
AudioMixerUtility.RepaintAudioMixerAndInspectors();
292292
}
293293
}

Editor/Mono/BuildPlayerWindow.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ static bool IsColorSpaceValid(BuildPlatform platform)
409409
{
410410
hasMinGraphicsAPI = !apis.Contains(GraphicsDeviceType.OpenGLES3) && !apis.Contains(GraphicsDeviceType.OpenGLES2);
411411
}
412+
else if (platform.targetGroup == BuildTargetGroup.WebGL)
413+
{
414+
// must have OpenGLES3-only
415+
hasMinGraphicsAPI = apis.Contains(GraphicsDeviceType.OpenGLES3) && !apis.Contains(GraphicsDeviceType.OpenGLES2);
416+
}
417+
412418
return hasMinGraphicsAPI && hasMinOSVersion;
413419
}
414420
else
@@ -459,7 +465,7 @@ static bool IsLightmapEncodingValid(BuildPlatform platform)
459465
{ "WindowsStandalone", "Windows" },
460466
{ "LinuxStandalone", "Linux" },
461467
{ "Facebook", "Facebook-Games"},
462-
{ "Metro", "Universal-Windows-Platform"}
468+
{ "UWP", "Universal-Windows-Platform"}
463469
};
464470
static public string GetPlaybackEngineDownloadURL(string moduleName)
465471
{

Editor/Mono/Camera/BuiltinBakedReflectionSystem.bindings.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using UnityEngine.Assertions;
99
using UnityEngine.Bindings;
1010
using UnityEngine.Scripting;
11+
using System.Collections.Generic;
1112

1213
namespace UnityEditor.Experimental.Rendering
1314
{
@@ -21,9 +22,12 @@ class BuiltinBakedReflectionSystem : IScriptableBakedReflectionSystem
2122
IScriptableBakedReflectionSystemStageNotifier m_Handle;
2223

2324
public int stageCount { get { return 3; } }
24-
[NativeProperty("StateHash")]
25-
extern Hash128 _stateHash { get; }
26-
public Hash128 stateHash { get { return _stateHash; } }
25+
26+
[NativeName("StateHashes")]
27+
extern public Hash128[] stateHashes
28+
{
29+
get;
30+
}
2731

2832
bool disposed { get { return m_Ptr == IntPtr.Zero; } }
2933

Editor/Mono/Camera/IScriptableBakedReflectionSystem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace UnityEditor.Experimental.Rendering
1010
public interface IScriptableBakedReflectionSystem : IDisposable
1111
{
1212
int stageCount { get; }
13-
Hash128 stateHash { get; }
13+
Hash128[] stateHashes { get; }
1414

1515
void Tick(SceneStateHash sceneStateHash, IScriptableBakedReflectionSystemStageNotifier handle);
1616
void SynchronizeReflectionProbes();

Editor/Mono/Camera/ScriptableBakedReflectionSystem.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ namespace UnityEditor.Experimental.Rendering
1010
public abstract class ScriptableBakedReflectionSystem : IScriptableBakedReflectionSystem
1111
{
1212
public int stageCount { get; }
13-
public Hash128 stateHash { get; protected set; }
13+
14+
public Hash128[] stateHashes { get; protected set; }
1415

1516
protected ScriptableBakedReflectionSystem(int stageCount)
1617
{

Editor/Mono/Camera/ScriptableBakedReflectionSystemWrapper.bindings.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ internal ScriptableBakedReflectionSystemWrapper(IntPtr ptr)
3030
Dispose(false);
3131
}
3232

33-
Hash128 Internal_ScriptableBakedReflectionSystemWrapper_stateHash
33+
Hash128[] Internal_ScriptableBakedReflectionSystemWrapper_stateHashes
3434
{
3535
[RequiredByNativeCode]
36-
get { return implementation != null ? implementation.stateHash : new Hash128(); }
36+
get { return implementation != null ? implementation.stateHashes : null; }
3737
}
3838

3939
int Internal_ScriptableBakedReflectionSystemWrapper_stageCount

Editor/Mono/ContainerWindow.bindings.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ internal enum ShowMode
2323
// Aux windows. The ones that close the moment you move the mouse out of them.
2424
AuxWindow = 5,
2525
// Like PopupMenu, but without keyboard focus
26-
Tooltip = 6
26+
Tooltip = 6,
27+
// Modal Utility window
28+
ModalUtility = 7
2729
}
2830

2931
//[StaticAccessor("ContainerWindowBindings", StaticAccessorType.DoubleColon)]

Editor/Mono/ContainerWindow.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void Show(ShowMode showMode, bool loadPosition, bool displayImmediately,
109109
if (showMode == ShowMode.AuxWindow)
110110
showMode = ShowMode.Utility;
111111

112-
if (showMode == ShowMode.Utility || IsPopup(showMode))
112+
if (showMode == ShowMode.Utility || showMode == ShowMode.ModalUtility || IsPopup(showMode))
113113
m_DontSaveToLayout = true;
114114

115115
m_ShowMode = (int)showMode;

Editor/Mono/EditorAssemblies.cs

+5-29
Original file line numberDiff line numberDiff line change
@@ -100,42 +100,18 @@ private static void SetLoadedEditorAssemblies(Assembly[] assemblies)
100100
m_subClasses.Clear();
101101
}
102102

103-
[NonSerialized]
104-
static ProfilerMarker s_ProcessInitializeOnLoadAttribute = new ProfilerMarker("ProcessInitializeOnLoadAttribute");
105-
106-
[NonSerialized]
107-
static ProfilerMarker s_ProcessInitializeOnLoadMethodAttribute = new ProfilerMarker("ProcessInitializeOnLoadMethodAttribute");
108-
109103
[RequiredByNativeCode]
110-
private static void ProcessInitializeOnLoadAttributes(Type[] types, MethodInfo[] methods)
104+
private static void ProcessInitializeOnLoadAttributes(Type[] types)
111105
{
112106
foreach (Type type in types)
113107
{
114-
using (s_ProcessInitializeOnLoadAttribute.Auto())
108+
try
115109
{
116-
try
117-
{
118-
RuntimeHelpers.RunClassConstructor(type.TypeHandle);
119-
}
120-
catch (TypeInitializationException x)
121-
{
122-
Debug.LogError(x.InnerException);
123-
}
110+
RuntimeHelpers.RunClassConstructor(type.TypeHandle);
124111
}
125-
}
126-
127-
foreach (MethodInfo method in methods)
128-
{
129-
using (s_ProcessInitializeOnLoadMethodAttribute.Auto())
112+
catch (TypeInitializationException x)
130113
{
131-
try
132-
{
133-
method.Invoke(null, null);
134-
}
135-
catch (TargetInvocationException x)
136-
{
137-
Debug.LogError(x.InnerException);
138-
}
114+
Debug.LogError(x.InnerException);
139115
}
140116
}
141117
}

Editor/Mono/EditorGUI.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,7 @@ private static float PowPreserveSign(float f, float p)
23572357
return f < 0.0f ? -result : result;
23582358
}
23592359

2360-
internal static void DoPropertyContextMenu(SerializedProperty property, SerializedProperty linkedProperty = null, GenericMenu menu = null)
2360+
internal static GenericMenu FillPropertyContextMenu(SerializedProperty property, SerializedProperty linkedProperty = null, GenericMenu menu = null)
23612361
{
23622362
if (linkedProperty != null && linkedProperty.serializedObject != property.serializedObject)
23632363
linkedProperty = null;
@@ -2462,6 +2462,13 @@ internal static void DoPropertyContextMenu(SerializedProperty property, Serializ
24622462
EditorApplication.contextualPropertyMenu(pm, property);
24632463
}
24642464

2465+
return pm;
2466+
}
2467+
2468+
internal static void DoPropertyContextMenu(SerializedProperty property, SerializedProperty linkedProperty = null, GenericMenu menu = null)
2469+
{
2470+
GenericMenu pm = FillPropertyContextMenu(property, linkedProperty, menu);
2471+
24652472
if (pm.GetItemCount() == 0)
24662473
{
24672474
return;

Editor/Mono/EditorHandles/ConeFrustrumHandle.cs

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ internal enum ConeHandles
2525
// 'range' is height of conefrustrum
2626
internal static Vector3 DoConeFrustrumHandle(Quaternion rotation, Vector3 position, Vector3 radiusAngleRange, ConeHandles showHandles)
2727
{
28+
if (Event.current.alt)
29+
showHandles = 0;
30+
2831
Vector3 forward = rotation * Vector3.forward;
2932
Vector3 up = rotation * Vector3.up;
3033
Vector3 right = rotation * Vector3.right;

Editor/Mono/EditorHandles/Disc.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static Quaternion Do(int id, Quaternion rotation, Vector3 position, Vecto
5353
}
5454
case EventType.MouseDown:
5555
// am I closest to the thingy?
56-
if (HandleUtility.nearestControl == id && evt.button == 0)
56+
if (HandleUtility.nearestControl == id && evt.button == 0 && !evt.alt)
5757
{
5858
GUIUtility.hotControl = id; // Grab mouse focus
5959
Tools.LockHandlePosition();
@@ -134,7 +134,7 @@ public static Quaternion Do(int id, Quaternion rotation, Vector3 position, Vecto
134134
temp = Handles.color;
135135
Handles.color = Handles.selectedColor;
136136
}
137-
else if (id == HandleUtility.nearestControl && GUIUtility.hotControl == 0)
137+
else if (id == HandleUtility.nearestControl && GUIUtility.hotControl == 0 && !evt.alt)
138138
{
139139
temp = Handles.color;
140140
Handles.color = Handles.preselectionColor;

Editor/Mono/EditorHandles/FreeRotate.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal static Quaternion Do(int id, Quaternion rotation, Vector3 position, flo
3333
break;
3434
case EventType.MouseDown:
3535
// am I closest to the thingy?
36-
if (HandleUtility.nearestControl == id && evt.button == 0)
36+
if (HandleUtility.nearestControl == id && evt.button == 0 && !evt.alt)
3737
{
3838
GUIUtility.hotControl = id; // Grab mouse focus
3939
Tools.LockHandlePosition();
@@ -104,7 +104,7 @@ internal static Quaternion Do(int id, Quaternion rotation, Vector3 position, flo
104104
case EventType.Repaint:
105105
Color temp = Color.white;
106106
var isHot = id == GUIUtility.hotControl;
107-
var isPreselected = id == HandleUtility.nearestControl && GUIUtility.hotControl == 0;
107+
var isPreselected = id == HandleUtility.nearestControl && GUIUtility.hotControl == 0 && !evt.alt;
108108

109109
if (isHot)
110110
{

Editor/Mono/EditorHandles/PositionHandle.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ static Vector3 DoPlanarHandle(
364364
var updateOpacityFillColor = false;
365365
if (GUIUtility.hotControl == id)
366366
color = selectedColor;
367-
else if (HandleUtility.nearestControl == id)
367+
else if (HandleUtility.nearestControl == id && !Event.current.alt)
368368
color = preselectionColor;
369369
else
370370
updateOpacityFillColor = true;

0 commit comments

Comments
 (0)