Skip to content

Commit 906c689

Browse files
author
Unity Technologies
committed
Unity 2023.2.0a22 C# reference source code
1 parent e7d9de5 commit 906c689

File tree

796 files changed

+11048
-5239
lines changed

Some content is hidden

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

796 files changed

+11048
-5239
lines changed

Editor/Mono/ActiveEditorTracker.bindings.cs

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

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

6161
[FreeFunction]
62-
internal static extern void Internal_GetActiveEditorsNonAlloc(ActiveEditorTracker self, Editor[] editors);
62+
internal static extern void Internal_GetActiveEditorsNonAlloc(ActiveEditorTracker self, [Unmarshalled] Editor[] editors);
6363

6464
// List<T> version
6565
internal void GetObjectsLockedByThisTracker(List<UnityObject> lockedObjects)

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static AnimationClip[] GetAnimationClips(GameObject gameObject)
134134
extern internal static AnimationClip[] GetAnimationClipsInAnimationPlayer([NotNull] GameObject gameObject);
135135

136136
// Sets the array of AnimationClips to be referenced in the Animation component
137-
extern public static void SetAnimationClips([NotNull] Animation animation, AnimationClip[] clips);
137+
extern public static void SetAnimationClips([NotNull] Animation animation, [Unmarshalled] AnimationClip[] clips);
138138

139139
public static EditorCurveBinding[] GetAnimatableBindings(GameObject targetObject, GameObject root)
140140
{
@@ -201,7 +201,7 @@ public static Type PropertyModificationToEditorCurveBinding(PropertyModification
201201

202202
extern public static ObjectReferenceKeyframe[] GetObjectReferenceCurve([NotNull] AnimationClip clip, EditorCurveBinding binding);
203203

204-
public static void SetObjectReferenceCurve(AnimationClip clip, EditorCurveBinding binding, ObjectReferenceKeyframe[] keyframes)
204+
public static void SetObjectReferenceCurve(AnimationClip clip, EditorCurveBinding binding, [Unmarshalled]ObjectReferenceKeyframe[] keyframes)
205205
{
206206
Internal_SetObjectReferenceCurve(clip, binding, keyframes, true);
207207
Internal_InvokeOnCurveWasModified(clip, binding, keyframes != null ? CurveModifiedType.CurveModified : CurveModifiedType.CurveDeleted);
@@ -232,7 +232,7 @@ internal static void SetObjectReferenceCurveNoSync(AnimationClip clip, EditorCur
232232
}
233233

234234
[NativeThrows]
235-
extern private static void Internal_SetObjectReferenceCurve([NotNull] AnimationClip clip, EditorCurveBinding binding, ObjectReferenceKeyframe[] keyframes, bool updateMuscleClip);
235+
extern private static void Internal_SetObjectReferenceCurve([NotNull] AnimationClip clip, EditorCurveBinding binding, [Unmarshalled] ObjectReferenceKeyframe[] keyframes, bool updateMuscleClip);
236236

237237
extern public static AnimationCurve GetEditorCurve([NotNull] AnimationClip clip, EditorCurveBinding binding);
238238

Editor/Mono/AnimatorController.bindings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extern public AnimatorControllerLayer[] layers
3333
[FreeFunction(Name = "AnimatorControllerBindings::GetLayers", HasExplicitThis = true)]
3434
get;
3535
[FreeFunction(Name = "AnimatorControllerBindings::SetLayers", HasExplicitThis = true, ThrowsException = true)]
36+
[param: Unmarshalled]
3637
set;
3738
}
3839

@@ -41,6 +42,7 @@ extern public AnimatorControllerParameter[] parameters
4142
[FreeFunction(Name = "AnimatorControllerBindings::GetParameters", HasExplicitThis = true)]
4243
get;
4344
[FreeFunction(Name = "AnimatorControllerBindings::SetParameters", HasExplicitThis = true, ThrowsException = true)]
45+
[param: Unmarshalled]
4446
set;
4547
}
4648

@@ -133,6 +135,6 @@ internal extern bool isAssetBundled
133135
extern internal ScriptableObject[] Internal_GetEffectiveBehaviours([NotNull] AnimatorState state, int layerIndex);
134136

135137
[FreeFunction(Name = "AnimatorControllerBindings::Internal_SetEffectiveBehaviours", HasExplicitThis = true)]
136-
extern internal void Internal_SetEffectiveBehaviours([NotNull] AnimatorState state, int layerIndex, ScriptableObject[] behaviours);
138+
extern internal void Internal_SetEffectiveBehaviours([NotNull] AnimatorState state, int layerIndex, [Unmarshalled] ScriptableObject[] behaviours);
137139
}
138140
}

Editor/Mono/AssemblyHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static string[] GetDefaultAssemblySearchPaths()
5353
// Required for MonoBehaviour derived types like UIBehaviour that
5454
// were previous in a precompiled UnityEngine.UI.dll, but are now
5555
// compiled in a package.
56-
searchPaths.Add("Library/ScriptAssemblies");
56+
searchPaths.Add(InternalEditorUtility.GetEditorScriptAssembliesPath());
5757

5858
return searchPaths.ToArray();
5959
}

Editor/Mono/Audio/Analytics/AudioAnalytics.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,4 @@ namespace UnityEditor.Audio.Analytics;
1010

1111
static class AudioAnalytics
1212
{
13-
const string k_VendorKey = "unity.audio";
14-
15-
internal static bool RegisterEvent(string eventName, int maxEventsPerHour, int maxNumberOfElements)
16-
{
17-
var result = EditorAnalytics.RegisterEventWithLimit(eventName, maxEventsPerHour, maxNumberOfElements, k_VendorKey);
18-
19-
if (result == AnalyticsResult.Ok)
20-
{
21-
return true;
22-
}
23-
24-
Console.WriteLine($"Event '{eventName}' could not be registered.");
25-
return false;
26-
}
2713
}

Editor/Mono/Audio/Analytics/AudioRandomContainerBuildAnalyticsEvent.cs

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,46 @@
77
using UnityEditor.Build.Reporting;
88
using UnityEngine;
99
using UnityEngine.Audio;
10+
using UnityEngine.Analytics;
1011

1112
namespace UnityEditor.Audio.Analytics;
1213

1314
class AudioRandomContainerBuildAnalyticsEvent : IPostprocessBuildWithReport
1415
{
15-
const string k_EventName = "audioRandomContainerBuild";
16-
const int k_MaxEventsPerHour = 60;
17-
const int k_MaxNumberOfElements = 2;
16+
[AnalyticInfo(eventName: "audioRandomContainerBuild", vendorKey: "unity.audio", maxEventsPerHour: 60, maxNumberOfElements: 2)]
17+
internal class AudioRandomAnalytic : IAnalytic
18+
{
19+
public AudioRandomAnalytic(string build_guid, int count)
20+
{
21+
this.build_guid = build_guid;
22+
this.count = count;
23+
}
24+
25+
[Serializable]
26+
struct Payload : IAnalytic.IData
27+
{
28+
public string build_guid;
29+
public int count;
30+
}
1831

19-
static bool s_Initialized;
2032

21-
static bool Initialized
22-
{
23-
get
33+
public bool TryGatherData(out IAnalytic.IData data, out Exception error)
2434
{
25-
if (!s_Initialized)
35+
error = null;
36+
data = new Payload
2637
{
27-
s_Initialized = AudioAnalytics.RegisterEvent(k_EventName, k_MaxEventsPerHour, k_MaxNumberOfElements);
28-
}
38+
build_guid = build_guid,
39+
count = count
40+
};
2941

30-
return s_Initialized;
42+
return data != null;
3143
}
44+
45+
private string build_guid;
46+
private int count;
3247
}
3348

49+
3450
public int callbackOrder { get; }
3551

3652
public void OnPostprocessBuild(BuildReport report)
@@ -42,7 +58,6 @@ static void SendEvent(BuildReport report)
4258
{
4359
if (!EditorAnalytics.enabled
4460
|| AudioSettings.unityAudioDisabled
45-
|| !Initialized
4661
|| report == null
4762
|| report.packedAssets.Length == 0)
4863
{
@@ -64,18 +79,7 @@ static void SendEvent(BuildReport report)
6479
}
6580
}
6681

67-
var payload = new Payload
68-
{
69-
build_guid = report.summary.guid.ToString(),
70-
count = count
71-
};
72-
73-
EditorAnalytics.SendEventWithLimit(k_EventName, payload);
74-
}
75-
76-
struct Payload
77-
{
78-
public string build_guid;
79-
public int count;
82+
EditorAnalytics.SendAnalytic(new AudioRandomAnalytic(report.summary.guid.ToString(), count));
8083
}
81-
}
84+
85+
}

Editor/Mono/Audio/Analytics/AudioRandomContainerQuitAnalyticsEvent.cs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,40 @@
44

55
using System;
66
using UnityEngine;
7+
using UnityEngine.Analytics;
78

89
namespace UnityEditor.Audio.Analytics;
910

1011
[InitializeOnLoad]
1112
class AudioRandomContainerQuitAnalyticsEvent
1213
{
13-
const string k_EventName = "audioRandomContainerQuit";
14-
const int k_MaxEventsPerHour = 60;
15-
const int k_MaxNumberOfElements = 1;
14+
[AnalyticInfo(eventName: "audioRandomContainerQuit", vendorKey: "unity.audio", maxEventsPerHour: 60, maxNumberOfElements: 1)]
15+
internal class AudioRandomAnalytic : IAnalytic
16+
{
17+
public AudioRandomAnalytic(int count)
18+
{
19+
this.count = count;
20+
}
1621

17-
static bool s_Initialized;
22+
[Serializable]
23+
struct Payload : IAnalytic.IData
24+
{
25+
public int count;
26+
}
1827

19-
static bool Initialized
20-
{
21-
get
28+
29+
public bool TryGatherData(out IAnalytic.IData data, out Exception error)
2230
{
23-
if (!s_Initialized)
31+
error = null;
32+
data = new Payload
2433
{
25-
s_Initialized = AudioAnalytics.RegisterEvent(k_EventName, k_MaxEventsPerHour, k_MaxNumberOfElements);
26-
}
34+
count = count
35+
};
2736

28-
return s_Initialized;
37+
return data != null;
2938
}
39+
40+
private int count;
3041
}
3142

3243
static AudioRandomContainerQuitAnalyticsEvent()
@@ -42,18 +53,12 @@ static bool OnEditorApplicationWantsToQuit()
4253

4354
static void SendEvent()
4455
{
45-
if (!EditorAnalytics.enabled || AudioSettings.unityAudioDisabled || !Initialized)
56+
if (!EditorAnalytics.enabled || AudioSettings.unityAudioDisabled)
4657
{
4758
return;
4859
}
4960

5061
var assetPaths = AssetDatabase.FindAssets("t:AudioRandomContainer");
51-
var payload = new Payload { count = assetPaths.Length };
52-
EditorAnalytics.SendEventWithLimit(k_EventName, payload);
53-
}
54-
55-
struct Payload
56-
{
57-
public int count;
62+
EditorAnalytics.SendAnalytic(new AudioRandomAnalytic(assetPaths.Length));
5863
}
5964
}

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public GUIContent GetDownloadErrorForTarget(BuildTarget target)
7676
public GUIContent explicitNullChecks = EditorGUIUtility.TrTextContent("Explicit Null Checks");
7777
public GUIContent explicitDivideByZeroChecks = EditorGUIUtility.TrTextContent("Divide By Zero Checks");
7878
public GUIContent explicitArrayBoundsChecks = EditorGUIUtility.TrTextContent("Array Bounds Checks");
79-
public GUIContent learnAboutUnityCloudBuild = EditorGUIUtility.TrTextContent("Learn about Unity Cloud Build");
79+
public GUIContent learnAboutUnityCloudBuild = EditorGUIUtility.TrTextContent("Learn about Unity Build Automation");
8080
public GUIContent compressionMethod = EditorGUIUtility.TrTextContent("Compression Method", "Compression applied to Player data (scenes and resources).\nDefault - none or default platform compression.\nLZ4 - fast compression suitable for Development Builds.\nLZ4HC - higher compression rate variance of LZ4, causes longer build times. Works best for Release Builds.");
8181

8282
public readonly GUIContent assetImportOverrides = EditorGUIUtility.TrTextContent("Asset Import Overrides", "Asset import overrides for local development. Reducing maximum texture size or compression settings can speed up asset imports and platform switches.");

Editor/Mono/CodeEditor/CodeEditorAnalytics.cs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,44 @@
22
// Copyright (c) Unity Technologies. For terms of use, see
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

5+
using System;
56
using UnityEditor;
7+
using UnityEngine;
68
using UnityEngine.Analytics;
79

810
namespace Unity.CodeEditor
911
{
1012
class CodeEditorAnalytics
1113
{
12-
static bool s_EventRegistered = false;
13-
const int k_MaxEventsPerHour = 1000;
14-
const int k_MaxNumberOfElements = 1000;
15-
const string k_VendorKey = "unity.codeeditor";
16-
const string k_EventName = "CodeEditorUsage";
17-
18-
struct AnalyticsData
14+
[AnalyticInfo(eventName: "CodeEditorUsage", vendorKey: "unity.codeeditor")]
15+
public class CodeEditorAnalytic : IAnalytic
1916
{
20-
public string code_editor;
21-
}
17+
private IExternalCodeEditor codeEditor = null;
2218

23-
static bool EnableAnalytics()
24-
{
25-
AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(k_EventName, k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey);
26-
if (result == AnalyticsResult.Ok)
27-
s_EventRegistered = true;
19+
public CodeEditorAnalytic(IExternalCodeEditor codeEditor)
20+
{
21+
this.codeEditor = codeEditor;
22+
}
23+
24+
struct AnalyticsData : IAnalytic.IData
25+
{
26+
[SerializeField] public string code_editor;
27+
}
28+
public bool TryGatherData(out IAnalytic.IData data, out Exception error)
29+
{
30+
data = new AnalyticsData()
31+
{
32+
code_editor = codeEditor.GetType().FullName
33+
};
2834

29-
return s_EventRegistered;
35+
error = null;
36+
return true;
37+
}
3038
}
3139

3240
public static void SendCodeEditorUsage(IExternalCodeEditor codeEditor)
3341
{
34-
if (!EnableAnalytics())
35-
return;
36-
37-
var data = new AnalyticsData()
38-
{
39-
code_editor = codeEditor.GetType().FullName
40-
};
41-
EditorAnalytics.SendEventWithLimit(k_EventName, data);
42-
}
42+
EditorAnalytics.SendAnalytic(new CodeEditorAnalytic(codeEditor));
43+
}
4344
}
4445
}

Editor/Mono/ConsoleWindow.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ internal static void UpdateLogStyleFixedHeights()
164164
Vector2 m_TextScroll = Vector2.zero;
165165

166166
int m_LastActiveEntryIndex = -1;
167+
[NonSerialized]
168+
int m_IndexHintCache;
167169
bool m_RestoreLatestSelection;
168170

169171
//Make sure the minimum height of the panels can accomodate the cpmplete scroll bar icons
@@ -453,7 +455,8 @@ void SetActiveEntry(LogEntry entry)
453455
m_ActiveMode = (Mode)entry.mode;
454456
entry.callstackTextStartUTF8 = entry.message.Length;
455457
m_CallstackTextStart = entry.callstackTextStartUTF16;
456-
var entryRow = LogEntries.GetEntryRowIndex(entry.globalLineIndex);
458+
var entryRow = LogEntries.GetEntryRowIndex(entry.globalLineIndex, m_IndexHintCache);
459+
m_IndexHintCache = entryRow;
457460
// ping object referred by the log entry
458461
if (entry.instanceID != 0 && m_LastPingedEntryRow != entryRow)
459462
{

Editor/Mono/ContainerWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ public bool IsMainWindow()
492492
internal void SaveGeometry()
493493
{
494494
string ID = windowID;
495-
if (string.IsNullOrEmpty(ID))
495+
if (string.IsNullOrEmpty(ID) || IsValidContextMenu())
496496
return;
497497

498498
// save position/size
@@ -511,7 +511,7 @@ public void Save()
511511

512512
bool IsValidContextMenu()
513513
{
514-
return string.Equals(s_ContextMenuID, windowID) && m_PixelRect.x == 0 && m_PixelRect.y == 0;
514+
return string.Equals(s_ContextMenuID, windowID);
515515
}
516516

517517
internal void LoadGeometry(bool loadPosition)

Editor/Mono/EditorGraphicsSettings.bindings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using UnityEditor.Build;
7+
using UnityEditor.Rendering.Settings;
78
using UnityEngine.Bindings;
89
using UnityEngine.Rendering;
910
using Object = UnityEngine.Object;
@@ -59,7 +60,10 @@ public static void SetRenderPipelineGlobalSettingsAsset(Type renderPipelineType,
5960
CheckRenderPipelineType(renderPipelineType);
6061

6162
if (newSettings != null)
63+
{
64+
RenderPipelineGraphicsSettingsManager.PopulateRenderPipelineGraphicsSettings(newSettings);
6265
Internal_RegisterRenderPipeline(renderPipelineType.FullName, newSettings);
66+
}
6367
else
6468
Internal_UnregisterRenderPipeline(renderPipelineType.FullName);
6569
}

Editor/Mono/EditorSceneManager.bindings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ internal static void RemapAssetReferencesInScene(UnityEngine.SceneManagement.Sce
241241
[NativeThrows]
242242
[StaticAccessor("EditorSceneManagerBindings", StaticAccessorType.DoubleColon)]
243243
[NativeMethod("RestoreSceneManagerSetup")]
244-
public extern static void RestoreSceneManagerSetup(SceneSetup[] value);
244+
public extern static void RestoreSceneManagerSetup([Unmarshalled] SceneSetup[] value);
245245

246246
[StaticAccessor("EditorSceneManagerBindings", StaticAccessorType.DoubleColon)]
247247
[NativeMethod("LoadSceneManagerSetup")]

0 commit comments

Comments
 (0)