Skip to content

Commit 6c8a95f

Browse files
author
Unity Technologies
committed
Unity 2023.3.0b10 C# reference source code
1 parent 2a49d60 commit 6c8a95f

File tree

97 files changed

+1129
-635
lines changed

Some content is hidden

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

97 files changed

+1129
-635
lines changed

Editor/Mono/Animation/AnimatorController.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,15 @@ public void SetStateEffectiveMotion(AnimatorState state, Motion motion)
275275

276276
public void SetStateEffectiveMotion(AnimatorState state, Motion motion, int layerIndex)
277277
{
278+
//delete existing nested blend tree asset
279+
Motion selectedMotion = GetStateEffectiveMotion(state, layerIndex);
280+
BlendTree blendTree = selectedMotion as BlendTree;
281+
282+
if (blendTree != null && !AssetDatabase.IsMainAsset(blendTree))
283+
{
284+
MecanimUtilities.DestroyBlendTreeRecursive(blendTree);
285+
}
286+
278287
if (layers[layerIndex].syncedLayerIndex == -1)
279288
{
280289
undoHandler.DoUndo(state, "Set Motion");

Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ public override void OnImportAsset(AssetImportContext ctx)
182182
}
183183

184184
GameObject mainObject = new GameObject(ImporterSettings.kGameObjectName);
185+
186+
if (m_AdditionalSettings.generateRigidbody)
187+
{
188+
CreateAndAddRigidBodyToAsset(mainObject);
189+
}
190+
185191
ctx.AddObjectToAsset(ImporterSettings.kGameObjectName, mainObject);
186192
ctx.SetMainObject(mainObject);
187193

@@ -1321,6 +1327,16 @@ private bool TryGetShaderForCurrentRenderPipeline(STRenderPipeline renderPipelin
13211327
return shader != null;
13221328
}
13231329

1330+
private void CreateAndAddRigidBodyToAsset(GameObject mainObject)
1331+
{
1332+
Rigidbody rb = mainObject.AddComponent<Rigidbody>();
1333+
if (rb != null)
1334+
{
1335+
rb.useGravity = false;
1336+
rb.isKinematic = true;
1337+
}
1338+
}
1339+
13241340
private void CreateAndAddCollidersToAsset()
13251341
{
13261342
for (int iCollider = 0; iCollider < m_CollisionObjectsCount; ++iCollider)

Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9ImporterModelEditor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class SpeedTree9ImporterModelEditor : BaseSpeedTree9ImporterTabUI
4040
// Additional Settings properties
4141
private SerializedProperty m_MotionVectorModeEnumValue;
4242
private SerializedProperty m_GenerateColliders;
43+
private SerializedProperty m_GenerateRigidbody;
4344

4445
// LOD properties
4546
private SerializedProperty m_EnableSmoothLOD;
@@ -113,6 +114,7 @@ internal override void OnEnable()
113114

114115
m_MotionVectorModeEnumValue = FindPropertyFromName(addSettingsStr, nameof(addSettings.motionVectorModeEnumValue));
115116
m_GenerateColliders = FindPropertyFromName(addSettingsStr, nameof(addSettings.generateColliders));
117+
m_GenerateRigidbody = FindPropertyFromName(addSettingsStr, nameof(addSettings.generateRigidbody));
116118
}
117119

118120
// LOD properties
@@ -200,7 +202,8 @@ public override void OnInspectorGUI()
200202
// Additional Settings
201203
SpeedTreeImporterCommonEditor.ShowAdditionalSettingsGUI(
202204
ref m_MotionVectorModeEnumValue,
203-
ref m_GenerateColliders);
205+
ref m_GenerateColliders,
206+
ref m_GenerateRigidbody);
204207

205208
EditorGUILayout.Space();
206209

Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterCommon.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,14 @@ static internal void ShowLightingGUI(
276276

277277
static internal void ShowAdditionalSettingsGUI(
278278
ref SerializedProperty motionVectorModeEnumValue,
279-
ref SerializedProperty generateColliders)
279+
ref SerializedProperty generateColliders,
280+
ref SerializedProperty generateRigidbody)
280281
{
281282
GUILayout.Label(Styles.AdditionalSettingsHeader, EditorStyles.boldLabel);
282283
EditorGUILayout.Popup(motionVectorModeEnumValue, Styles.MotionVectorModeNames, Styles.MotionVectorMode);
283284

284285
EditorGUILayout.PropertyField(generateColliders);
286+
EditorGUILayout.PropertyField(generateRigidbody);
285287
}
286288

287289
static internal void ShowWindGUI(

Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ internal class AdditionalSettings
4848
{
4949
public MotionVectorGenerationMode motionVectorModeEnumValue = MotionVectorGenerationMode.Object;
5050
public bool generateColliders = true;
51+
public bool generateRigidbody = true;
5152
}
5253

5354
[Serializable]

Editor/Mono/AssetPipeline/SpeedTreeImporter.bindings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public extern bool isV8
9090
public extern int bestWindQuality { get; }
9191
public extern int selectedWindQuality { get; set; }
9292

93+
/////////////////////////////////////////////////////////////////////////////
94+
// Physics settings
95+
96+
public extern bool generateRigidbody { get; set; }
97+
public extern bool generateColliders { get; set; }
9398

9499
/////////////////////////////////////////////////////////////////////////////
95100
// LOD settings

Editor/Mono/BuildPipeline/DataBuildDirtyTracker.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,21 @@ static public bool CheckDirty(string buildDataPath, BuildOptions buildOptions, s
181181
if (!buildReportPath.FileExists())
182182
return true;
183183

184-
DataBuildDirtyTracker tracker = new DataBuildDirtyTracker()
184+
try
185185
{
186-
buildData = JsonUtility.FromJson<BuildData>(buildReportPath.ReadAllText()),
187-
scenes = scenes,
188-
buildOptions = buildOptions
189-
};
190-
return tracker.DoCheckDirty();
186+
DataBuildDirtyTracker tracker = new DataBuildDirtyTracker()
187+
{
188+
buildData = JsonUtility.FromJson<BuildData>(buildReportPath.ReadAllText()),
189+
scenes = scenes,
190+
buildOptions = buildOptions
191+
};
192+
return tracker.DoCheckDirty();
193+
}
194+
catch (Exception e)
195+
{
196+
Console.WriteLine($"Rebuilding Data files because the build data file is corrupt: {e}");
197+
return true;
198+
}
191199
}
192200
}
193201
}

Editor/Mono/BuildProfile/BuildProfileContext.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ void OnEnable()
282282
continue;
283283
}
284284

285+
if (!BuildProfileModuleUtil.IsModuleInstalled(profileObj.moduleName, profileObj.subtarget))
286+
continue;
287+
285288
m_BuildModuleNameToClassicPlatformProfile.Add((profileObj.moduleName, profileObj.subtarget), profileObj);
286289
classicPlatformProfiles.Add(profileObj);
287290
}

Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ internal class BuildProfileModuleUtil
3030
{
3131
"Switch",
3232
"QNX",
33-
"PS4",
34-
"PS5"
3533
};
3634

3735
/// <summary>

Editor/Mono/ContainerWindow.bindings.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ internal partial class ContainerWindow
3535
{
3636
private const string k_ScriptingPrefix = "ContainerWindowBindings::";
3737

38-
// Pixel-position on screen.
39-
public extern Rect position
38+
extern Rect Internal_Position
4039
{
4140
[FreeFunction(k_ScriptingPrefix + "GetPosition", HasExplicitThis = true)] get;
4241
[FreeFunction(k_ScriptingPrefix + "SetPosition", HasExplicitThis = true)] set;

Editor/Mono/ContainerWindow.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ private void OnDestroy()
7777
Internal_Destroy();
7878
}
7979

80+
// Pixel-position on screen.
81+
public Rect position
82+
{
83+
get => Internal_Position;
84+
set
85+
{
86+
if (!View.IsValidViewRect(value))
87+
throw new ArgumentException($"Invalid position: {value}");
88+
89+
Internal_Position = value;
90+
}
91+
}
92+
8093
internal ShowMode showMode => (ShowMode)m_ShowMode;
8194

8295
private string m_WindowID = null;
@@ -229,6 +242,12 @@ public void OnEnable()
229242

230243
public void SetMinMaxSizes(Vector2 min, Vector2 max)
231244
{
245+
if (!View.IsValidViewSize(min))
246+
throw new ArgumentException($"Invalid minimum size: {min}");
247+
248+
if (!View.IsValidViewSize(max))
249+
throw new ArgumentException($"Invalid maximum size: {max}");
250+
232251
m_MinSize = min;
233252
m_MaxSize = max;
234253
Rect r = position;

Editor/Mono/EditorMode/ModeService.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,12 @@ private static void LoadModes(bool checkStartupMode = false)
365365
Log("LoadModes");
366366

367367
ScanModes();
368-
var currentModeIndex = LoadProjectPrefModeIndex();
368+
369+
var currentModeIndex = GetSessionModeIndex();
370+
if (currentModeIndex == -1)
371+
{
372+
currentModeIndex = LoadProjectPrefModeIndex();
373+
}
369374
if (checkStartupMode && HasStartupMode())
370375
{
371376
var requestEditorMode = Application.GetValueForARGV("editor-mode");
@@ -380,6 +385,17 @@ private static void LoadModes(bool checkStartupMode = false)
380385
SetModeIndex(currentModeIndex);
381386
}
382387

388+
private static void SaveSessionMode()
389+
{
390+
SessionState.SetString(k_ModeCurrentIdKeyName, currentId);
391+
}
392+
393+
private static int GetSessionModeIndex()
394+
{
395+
var currentModeId = SessionState.GetString(k_ModeCurrentIdKeyName, "");
396+
return GetModeIndexById(currentModeId);
397+
}
398+
383399
internal static void InitializeCurrentMode()
384400
{
385401
if (initialModeChanged)
@@ -512,6 +528,8 @@ private static void SetModeIndex(int modeIndex)
512528
SessionState.SetBool(capName, (Boolean)state);
513529
}
514530
}
531+
532+
SaveSessionMode();
515533
}
516534

517535
private static int LoadProjectPrefModeIndex()

Editor/Mono/EditorWindow.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,11 @@ public Vector2 minSize
10991099
}
11001100
set
11011101
{
1102-
m_MinSize = value; MakeParentsSettingsMatchMe();
1102+
if (!View.IsValidViewSize(value))
1103+
throw new ArgumentException($"Invalid minSize: {value}");
1104+
1105+
m_MinSize = value;
1106+
MakeParentsSettingsMatchMe();
11031107
}
11041108
}
11051109

@@ -1112,6 +1116,9 @@ public Vector2 maxSize
11121116
}
11131117
set
11141118
{
1119+
if (!View.IsValidViewSize(value))
1120+
throw new ArgumentException($"Invalid minSize: {value}");
1121+
11151122
m_MaxSize = value;
11161123
MakeParentsSettingsMatchMe();
11171124
}

Editor/Mono/GUI/DockArea.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ protected override void OldOnGUI()
389389
ShowGenericMenu(position.width - genericMenuLeftOffset, m_TabAreaRect.y + genericMenuTopOffset);
390390
}
391391

392-
DrawTabs(m_TabAreaRect);
393392
HandleSplitView(); //fogbugz 1169963: in order to easily use the splitter in the gameView, it must be prioritized over DrawView(). Side effect for touch is that splitter picking zones might overlap other controls but the tabs still have higher priority so the user can undock the window in that case
393+
DrawTabs(m_TabAreaRect);
394394
DrawView(dockAreaRect);
395395

396396
DrawTabScrollers(m_TabAreaRect);

Editor/Mono/GUI/MainView.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected override void OnDestroy()
5353
protected override void SetPosition(Rect newPos)
5454
{
5555
base.SetPosition(newPos);
56+
newPos = position; // base.SetPosition does some sanitization so we have to use the position property instead of the newPos we received
5657
if (children.Length == 0)
5758
return;
5859
if (children.Length > 2)

Editor/Mono/ImportSettings/SpeedTreeImporterModelEditor.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ private class Styles
3636

3737
public static GUIContent AdditionalSettingsHeader = EditorGUIUtility.TrTextContent("Additional Settings");
3838
public static GUIContent MotionVectorMode = EditorGUIUtility.TrTextContent("Motion Vectors", "Motion vector mode to set for the mesh renderer of each LOD object");
39+
public static GUIContent GenerateRigidBody = EditorGUIUtility.TrTextContent("Generate Rigidbody", "Generates a Rigidbody in the root game object");
40+
public static GUIContent GenerateColliders = EditorGUIUtility.TrTextContent("Generate Colliders", "Generates mesh colliders for the LOD objects");
3941

4042
public static GUIContent WindHeader = EditorGUIUtility.TrTextContent("Wind");
4143
public static GUIContent WindQuality = EditorGUIUtility.TrTextContent("Wind Quality", "Controls the wind effect's quality.");
@@ -105,6 +107,10 @@ private class Styles
105107
private SerializedProperty m_BillboardTransitionCrossFadeWidth;
106108
private SerializedProperty m_FadeOutWidth;
107109

110+
// physics
111+
private SerializedProperty m_GenerateRigidbody;
112+
private SerializedProperty m_GenerateColliders;
113+
108114
private bool m_AllAreV8;
109115
private bool m_AllAreNotV8;
110116

@@ -153,6 +159,9 @@ internal override void OnEnable()
153159
m_BillboardTransitionCrossFadeWidth = serializedObject.FindProperty("m_BillboardTransitionCrossFadeWidth");
154160
m_FadeOutWidth = serializedObject.FindProperty("m_FadeOutWidth");
155161

162+
m_GenerateRigidbody = serializedObject.FindProperty("m_GenerateRigidbody");
163+
m_GenerateColliders = serializedObject.FindProperty("m_GenerateColliders");
164+
156165
m_ShowSmoothLODOptions.value = m_EnableSmoothLOD.hasMultipleDifferentValues || m_EnableSmoothLOD.boolValue;
157166
m_ShowSmoothLODOptions.valueChanged.AddListener(Repaint);
158167
m_ShowCrossFadeWidthOptions.value = m_AnimateCrossFading.hasMultipleDifferentValues || !m_AnimateCrossFading.boolValue;
@@ -289,6 +298,12 @@ private void ShowAdditionalSettingsGUI()
289298
EditorGUILayout.Popup(m_MotionVectorModeEnumValue, Styles.MotionVectorModeNames, Styles.MotionVectorMode);
290299

291300
EditorGUILayout.Space();
301+
302+
GUILayout.Label("Physics", EditorStyles.boldLabel);
303+
EditorGUILayout.PropertyField(m_GenerateRigidbody , Styles.GenerateRigidBody);
304+
EditorGUILayout.PropertyField(m_GenerateColliders, Styles.GenerateColliders);
305+
306+
EditorGUILayout.Space();
292307
}
293308

294309
public override void OnInspectorGUI()

Editor/Mono/Inspector/Core/ScriptAttributeGUI/PropertyHandler.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,25 @@ public void AddMenuItems(SerializedProperty property, GenericMenu menu)
400400
menu.AddItem(new GUIContent("Copy Property Path"), false, () => EditorGUIUtility.systemCopyBuffer = propertyPath);
401401

402402
if (CanSearchProperty(property))
403+
{
403404
menu.AddItem(new GUIContent("Search for same Property"), false, () => SearchProperty(property));
405+
if (property.propertyType == SerializedPropertyType.ObjectReference && property.objectReferenceValue)
406+
{
407+
menu.AddItem(new GUIContent($"Find references to {property.objectReferenceValue.GetType().Name} {property.objectReferenceValue.name}"), false, () => FindReferences(property.objectReferenceValue));
408+
}
409+
}
404410
}
405411

406412
private void SearchProperty(SerializedProperty property)
407413
{
408414
CommandService.Execute("OpenToSearchByProperty", CommandHint.Menu, property);
409415
}
410416

417+
private void FindReferences(UnityEngine.Object obj)
418+
{
419+
CommandService.Execute("OpenToFindReferenceOnObject", CommandHint.Menu, obj);
420+
}
421+
411422
private bool CanSearchProperty(SerializedProperty property)
412423
{
413424
if (!CommandService.Exists("OpenToSearchByProperty") || !CommandService.Exists("IsPropertyValidForQuery"))

0 commit comments

Comments
 (0)