Skip to content

Commit 313479b

Browse files
author
Unity Technologies
committed
Unity 2023.2.0a10 C# reference source code
1 parent 6ac92f7 commit 313479b

File tree

115 files changed

+2582
-611
lines changed

Some content is hidden

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

115 files changed

+2582
-611
lines changed

Editor/Mono/ActiveEditorTracker.bindings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public override int GetHashCode()
5555
public void Destroy() { Internal_Destroy(this); }
5656

5757
[FreeFunction]
58-
static extern Array Internal_GetActiveEditors(ActiveEditorTracker self);
59-
public Editor[] activeEditors { get { return (Editor[])Internal_GetActiveEditors(this); } }
58+
static extern Editor[] Internal_GetActiveEditors(ActiveEditorTracker self);
59+
public Editor[] activeEditors { get { return Internal_GetActiveEditors(this); } }
6060

6161
[FreeFunction]
6262
internal static extern void Internal_GetActiveEditorsNonAlloc(ActiveEditorTracker self, Editor[] editors);

Editor/Mono/Animation/AnimationWindow/AnimationWindowEvent.cs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,46 @@
1313

1414
namespace UnityEditor
1515
{
16-
internal struct AnimationWindowEventMethod
16+
/// <summary>
17+
/// Holds the context for AnimationEvent editing.
18+
/// </summary>
19+
class AnimationEventEditorState
1720
{
18-
public string name;
19-
public Type parameterType;
21+
static bool s_ShowOverloadedFunctionsDetails = true;
22+
static bool s_ShowDuplicatedFunctionsDetails = true;
23+
24+
bool m_ShowOverloadedFunctionsDetails = s_ShowOverloadedFunctionsDetails;
25+
bool m_ShowDuplicatedFunctionsDetails = s_ShowDuplicatedFunctionsDetails;
26+
27+
/// <summary>
28+
/// Used to track whether or not to show extra details about duplicated function names found in among the potential supported functions
29+
/// </summary>
30+
public bool ShowOverloadedFunctionsDetails
31+
{
32+
get => m_ShowOverloadedFunctionsDetails;
33+
set
34+
{
35+
m_ShowOverloadedFunctionsDetails = s_ShowOverloadedFunctionsDetails = value;
36+
}
37+
}
38+
39+
/// <summary>
40+
/// Used to track whether or not to show extra details about overloaded function names found in among the potential supported functions
41+
/// </summary>
42+
public bool ShowDuplicatedFunctionsDetails
43+
{
44+
get => m_ShowDuplicatedFunctionsDetails;
45+
set
46+
{
47+
m_ShowDuplicatedFunctionsDetails = s_ShowDuplicatedFunctionsDetails = value;
48+
}
49+
}
50+
51+
public AnimationEventEditorState()
52+
{
53+
m_ShowOverloadedFunctionsDetails = s_ShowOverloadedFunctionsDetails;
54+
m_ShowDuplicatedFunctionsDetails = s_ShowDuplicatedFunctionsDetails;
55+
}
2056
}
2157

2258
internal class AnimationWindowEvent : ScriptableObject

Editor/Mono/Animation/AnimationWindow/AnimationWindowEventInspector.cs

Lines changed: 184 additions & 79 deletions
Large diffs are not rendered by default.

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,9 @@
139139

140140
[assembly: InternalsVisibleTo("Unity.Scenes")]
141141

142+
// This should move with the AnimationWindow to a module at some point
143+
[assembly: InternalsVisibleTo("UnityEditor.Modules.Animation.tests.AnimationWindow")]
144+
145+
[assembly: InternalsVisibleTo("UnityEditor.Modules.Physics.Tests")]
146+
142147
[assembly: AssemblyIsEditorAssembly]

Editor/Mono/Audio/AudioContainerWindow.cs

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ sealed class AudioContainerWindow : EditorWindow
6666
Texture2D m_DiceIconOff;
6767
Texture2D m_DiceIconOn;
6868

69+
bool m_IsLoading;
70+
6971
List<AudioContainerElement> m_CachedElements;
7072

7173
List<AudioContainerElement> CachedElements
@@ -83,8 +85,7 @@ internal static void CreateAudioRandomContainerWindow()
8385
}
8486

8587
/// <summary>
86-
/// Updates the state to reflect selection changes,
87-
/// which will implicitly refresh the window content if necessary.
88+
/// Updates the state, which will implicitly refresh the window content if needed.
8889
/// </summary>
8990
internal void Refresh()
9091
{
@@ -142,22 +143,36 @@ void SetTitle(bool targetIsDirty)
142143

143144
void CreateGUI()
144145
{
145-
rootVisualElement.Unbind();
146-
rootVisualElement.Clear();
147-
148-
if (m_State.AudioContainer == null)
146+
try
149147
{
150-
return;
151-
}
148+
if (m_IsLoading)
149+
{
150+
return;
151+
}
152152

153-
var rootAsset = LoadUxml("UXML/Audio/AudioRandomContainer.uxml");
154-
rootAsset.CloneTree(rootVisualElement);
153+
m_IsLoading = true;
155154

156-
var styleSheet = LoadStyleSheet("StyleSheets/Audio/AudioRandomContainer.uss");
157-
rootVisualElement.styleSheets.Add(styleSheet);
155+
rootVisualElement.Unbind();
156+
rootVisualElement.Clear();
158157

159-
CreateBindings();
160-
UpdateTransportButtonStates();
158+
if (m_State.AudioContainer == null)
159+
{
160+
return;
161+
}
162+
163+
var rootAsset = LoadUxml("UXML/Audio/AudioRandomContainer.uxml");
164+
rootAsset.CloneTree(rootVisualElement);
165+
166+
var styleSheet = LoadStyleSheet("StyleSheets/Audio/AudioRandomContainer.uss");
167+
rootVisualElement.styleSheets.Add(styleSheet);
168+
169+
CreateBindings();
170+
UpdateTransportButtonStates();
171+
}
172+
finally
173+
{
174+
m_IsLoading = false;
175+
}
161176
}
162177

163178
void CreateBindings()
@@ -629,7 +644,8 @@ void OnAudioClipDrag(List<AudioClip> audioClips)
629644
{
630645
var element = new AudioContainerElement
631646
{
632-
audioClip = audioClip
647+
audioClip = audioClip,
648+
hideFlags = HideFlags.HideInHierarchy
633649
};
634650
elements.Add(element);
635651
AssetDatabase.AddObjectToAsset(element, m_State.AudioContainer);
@@ -640,11 +656,6 @@ void OnAudioClipDrag(List<AudioClip> audioClips)
640656
m_State.AudioContainer.elements = elements.ToArray();
641657
}
642658

643-
void OnSelectionChange()
644-
{
645-
m_State.UpdateTarget();
646-
}
647-
648659
static VisualTreeAsset LoadUxml(string filePath)
649660
{
650661
var asset = EditorGUIUtility.Load(filePath) as VisualTreeAsset;

Editor/Mono/Audio/AudioContainerWindowState.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ sealed class AudioContainerWindowState
2323
internal AudioContainerWindowState()
2424
{
2525
EditorApplication.playModeStateChanged += OnEditorPlayModeStateChanged;
26+
Selection.selectionChanged += OnSelectionChanged;
2627
}
2728

2829
internal AudioRandomContainer AudioContainer
@@ -75,6 +76,7 @@ internal void OnDestroy()
7576
{
7677
Stop();
7778
EditorApplication.playModeStateChanged -= OnEditorPlayModeStateChanged;
79+
Selection.selectionChanged -= OnSelectionChanged;
7880

7981
if (m_PreviewAudioSource != null) Object.DestroyImmediate(m_PreviewAudioSource.gameObject);
8082
}
@@ -162,7 +164,7 @@ internal void UpdateTarget()
162164
}
163165
}
164166

165-
if (!audioClipSelected && newTarget != m_AudioContainer)
167+
if (!audioClipSelected && (newTarget != null && newTarget != m_AudioContainer))
166168
{
167169
if (m_AudioContainer != null)
168170
{
@@ -182,8 +184,6 @@ internal void UpdateTarget()
182184
}
183185
}
184186

185-
// Set up a hidden audio source in the scene for preview purposes
186-
187187
/// <summary>
188188
/// This method creates a hidden game object in the scene with an audio source for editor previewing purposes.
189189
/// The preview object is created with the window and destroyed when the window is closed.
@@ -232,4 +232,9 @@ void OnEditorPlayModeStateChanged(PlayModeStateChange state)
232232
Stop();
233233
}
234234
}
235+
236+
void OnSelectionChanged()
237+
{
238+
UpdateTarget();
239+
}
235240
}

Editor/Mono/Commands/GOCreationCommands.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ internal static void CreateEmptyParent()
196196
}
197197

198198
SceneHierarchyWindow.lastInteractedHierarchyWindow.SetExpanded(go.GetInstanceID(), true);
199+
200+
// Ensure empty parent after reparenting jumps into rename mode if needed UUM-15042
201+
if (SceneHierarchyWindow.s_EnterRenameModeForNewGO)
202+
{
203+
SceneHierarchyWindow.FrameAndRenameNewGameObject();
204+
}
199205
}
200206

201207
// Set back default parent object if we have one

Editor/Mono/EditorGUI.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,11 +4594,19 @@ internal static Vector3 LinkedVector3Field(Rect position, GUIContent label, GUI
45944594
GUIContent copy = label;
45954595
Rect fullLabelRect = position;
45964596

4597-
if(proportionalScaleProperty != null)
4597+
BeginChangeCheck();
4598+
4599+
if (proportionalScaleProperty != null)
4600+
{
45984601
BeginPropertyInternal(fullLabelRect, label, proportionalScaleProperty);
4602+
}
45994603

4604+
var scalePropertyId = -1;
46004605
if (property != null)
4606+
{
46014607
label = BeginPropertyInternal(position, label, property);
4608+
scalePropertyId = GUIUtility.keyboardControl;
4609+
}
46024610

46034611
SerializedProperty copiedProperty = property == null ? property : property.Copy();
46044612
var toggle = EditorStyles.toggle.CalcSize(GUIContent.none);
@@ -4627,13 +4635,26 @@ internal static Vector3 LinkedVector3Field(Rect position, GUIContent label, GUI
46274635
position.width -= toggle.x + kDefaultSpacing;
46284636
position.height = kSingleLineHeight;
46294637

4630-
var newValue = LinkedVector3Field(position, value, proportionalScale, mixedValues, initialScale, ref axisModified, copiedProperty);
4638+
if (proportionalScaleProperty != null)
4639+
{
4640+
EndProperty();
4641+
}
46314642

46324643
if (property != null)
4633-
EndProperty();
4644+
{
4645+
// Note: due to how both the scale + constrainScale property drawn and handled in a custom fashion, the lastcontrolId never correspond
4646+
// to the scaleProperty. Also s_PendingPropertyKeyboardHandling is nullifed by the constrainScale property.
4647+
// Make it work for now but I feel this whole system is super brittle.
4648+
// This will be hopefully fixed up when we use uitk to create these editors.
46344649

4635-
if(proportionalScaleProperty != null)
4650+
var lastId = EditorGUIUtility.s_LastControlID;
4651+
EditorGUIUtility.s_LastControlID = scalePropertyId;
4652+
s_PendingPropertyKeyboardHandling = property;
46364653
EndProperty();
4654+
EditorGUIUtility.s_LastControlID = lastId;
4655+
}
4656+
4657+
var newValue = LinkedVector3Field(position, value, proportionalScale, mixedValues, initialScale, ref axisModified, copiedProperty);
46374658

46384659
return newValue;
46394660
}
@@ -4652,7 +4673,6 @@ static Vector3 LinkedVector3Field(Rect position, Vector3 value, bool proportiona
46524673
s_Vector3Floats[1] = value.y;
46534674
s_Vector3Floats[2] = value.z;
46544675
position.height = kSingleLineHeight;
4655-
BeginChangeCheck();
46564676
const float kPrefixWidthOffset = 3.65f;
46574677
LockingMultiFloatFieldInternal(position, proportionalScale, mixedValues, s_XYZLabels, s_Vector3Floats, new float[] {initialScale.x, initialScale.y, initialScale.z}, property, EditorGUI.CalcPrefixLabelWidth(s_XYZLabels[0]) + kPrefixWidthOffset);
46584678
if (EndChangeCheck())
@@ -7029,6 +7049,8 @@ private static void DoPropertyFieldKeyboardHandling(SerializedProperty property)
70297049
// Copy & Paste
70307050
if (evt.commandName == EventCommandNames.Copy || evt.commandName == EventCommandNames.Paste)
70317051
{
7052+
if (evt.commandName == EventCommandNames.Paste)
7053+
GUI.changed = true;
70327054
ClipboardContextMenu.SetupPropertyCopyPaste(property, menu: null, evt: evt);
70337055
}
70347056
}

Editor/Mono/GUI/InternalEditorGUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ internal static Vector2 MouseDeltaReader(Rect position, bool activated)
197197

198198
private static GUIStyle s_LargeSplitLeftStyle;
199199
private static GUIStyle s_LargeSplitRightStyle;
200-
internal static bool LargeSplitButtonWithDropdownList(GUIContent content, string[] buttonNames, GenericMenu.MenuFunction2 callback)
200+
public static bool LargeSplitButtonWithDropdownList(GUIContent content, string[] buttonNames, GenericMenu.MenuFunction2 callback)
201201
{
202202
// Load required styles
203203
if (s_LargeSplitLeftStyle == null)

Editor/Mono/GUI/Tools/BuiltinTools.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ protected override void ToolGUI(SceneView view, Vector3 handlePosition, bool isS
591591
TransformManipulator.BeginManipulationHandling(false);
592592
// Move handle
593593
EditorGUI.BeginChangeCheck();
594-
Vector3 newPos = MoveHandlesGUI(rect, rectRotation * rect.center + handlePosition, rectRotation);
594+
Vector3 newPos = MoveHandlesGUI(rect, handlePosition, rectRotation);
595595
if (EditorGUI.EndChangeCheck() && !isStatic)
596596
{
597597
if (GridSnapping.active)
@@ -932,10 +932,13 @@ static Vector3 MoveHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation)
932932
}
933933
else
934934
{
935+
// https://jira.unity3d.com/browse/UUM-30232
936+
// https://jira.unity3d.com/browse/UUM-18037
937+
var repaintPivot = rotation * rect.center + pivot;
935938
Handles.color = Handles.secondaryColor * new Color(1, 1, 1, 1.5f * discOpacity);
936-
Handles.CircleHandleCap(id, pivot, rotation, discSize, EventType.Repaint);
939+
Handles.CircleHandleCap(id, repaintPivot, rotation, discSize, EventType.Repaint);
937940
Handles.color = Handles.secondaryColor * new Color(1, 1, 1, 0.3f * discOpacity);
938-
Handles.DrawSolidDisc(pivot, rotation * Vector3.forward, discSize);
941+
Handles.DrawSolidDisc(repaintPivot, rotation * Vector3.forward, discSize);
939942
}
940943
break;
941944
}

0 commit comments

Comments
 (0)