Skip to content

Commit b42ec00

Browse files
author
Unity Technologies
committed
Unity 6000.2.0a4 C# reference source code
1 parent efc9c4d commit b42ec00

File tree

214 files changed

+3443
-1759
lines changed

Some content is hidden

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

214 files changed

+3443
-1759
lines changed

Editor/Mono/2D/SpriteAtlas/EditorSpriteAtlas.bindings.cs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,23 @@ internal static void RegisterAndPackAtlas(this SpriteAtlas spriteAtlas, AssetImp
111111
extern public static void SetTextureSettings([NotNull] this SpriteAtlas spriteAtlas, SpriteAtlasTextureSettings src);
112112
extern public static SpriteAtlasPackingSettings GetPackingSettings([NotNull] this SpriteAtlas spriteAtlas);
113113
extern public static void SetPackingSettings([NotNull] this SpriteAtlas spriteAtlas, SpriteAtlasPackingSettings src);
114-
extern public static TextureImporterPlatformSettings GetPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, string buildTarget);
115-
extern public static void SetPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src);
114+
115+
[NativeName("GetPlatformSettings")]
116+
extern private static TextureImporterPlatformSettings GetPlatformSettings_Internal([NotNull] this SpriteAtlas spriteAtlas, string buildTarget);
117+
public static TextureImporterPlatformSettings GetPlatformSettings(this SpriteAtlas spriteAtlas, string buildTarget)
118+
{
119+
buildTarget = TextureImporter.GetTexturePlatformSerializationName(buildTarget); // String may refer to a platform group: if != "Standalone", ensure it refers to a platform instead. E.g.: "iOS", not "iPhone".
120+
return GetPlatformSettings_Internal(spriteAtlas, buildTarget);
121+
}
122+
123+
[NativeName("SetPlatformSettings")]
124+
extern private static void SetPlatformSettings_Internal([NotNull] this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src);
125+
public static void SetPlatformSettings(this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src)
126+
{
127+
src.name = TextureImporter.GetTexturePlatformSerializationName(src.name); // String may refer to a platform group: if != "Standalone", ensure it refers to a platform instead. E.g.: "iOS", not "iPhone".
128+
SetPlatformSettings_Internal(spriteAtlas, src);
129+
}
130+
116131
extern public static void SetIncludeInBuild([NotNull] this SpriteAtlas spriteAtlas, bool value);
117132
extern public static void SetIsVariant([NotNull] this SpriteAtlas spriteAtlas, bool value);
118133
extern public static void SetMasterAtlas([NotNull] this SpriteAtlas spriteAtlas, SpriteAtlas value);
@@ -126,8 +141,23 @@ internal static void RegisterAndPackAtlas(this SpriteAtlas spriteAtlas, AssetImp
126141
extern internal static TextureFormat GetTextureFormat([NotNull] this SpriteAtlas spriteAtlas, BuildTarget target);
127142
extern internal static Sprite[] GetPackedSprites([NotNull] this SpriteAtlas spriteAtlas);
128143
extern internal static Hash128 GetStoredHash([NotNull] this SpriteAtlas spriteAtlas);
129-
extern internal static TextureImporterPlatformSettings GetSecondaryPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, string buildTarget, string secondaryTextureName);
130-
extern internal static void SetSecondaryPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src, string secondaryTextureName);
144+
145+
[NativeName("GetSecondaryPlatformSettings")]
146+
extern private static TextureImporterPlatformSettings GetSecondaryPlatformSettings_Internal([NotNull] this SpriteAtlas spriteAtlas, string buildTarget, string secondaryTextureName);
147+
internal static TextureImporterPlatformSettings GetSecondaryPlatformSettings(this SpriteAtlas spriteAtlas, string buildTarget, string secondaryTextureName)
148+
{
149+
buildTarget = TextureImporter.GetTexturePlatformSerializationName(buildTarget); // String may refer to a platform group: if != "Standalone", ensure it refers to a platform instead. E.g.: "iOS", not "iPhone".
150+
return GetSecondaryPlatformSettings_Internal(spriteAtlas, buildTarget, secondaryTextureName);
151+
}
152+
153+
[NativeName("SetSecondaryPlatformSettings")]
154+
extern private static void SetSecondaryPlatformSettings_Internal([NotNull] this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src, string secondaryTextureName);
155+
internal static void SetSecondaryPlatformSettings(this SpriteAtlas spriteAtlas, TextureImporterPlatformSettings src, string secondaryTextureName)
156+
{
157+
src.name = TextureImporter.GetTexturePlatformSerializationName(src.name); // String may refer to a platform group: if != "Standalone", ensure it refers to a platform instead. E.g.: "iOS", not "iPhone".
158+
SetSecondaryPlatformSettings_Internal(spriteAtlas, src, secondaryTextureName);
159+
}
160+
131161
extern internal static bool GetSecondaryColorSpace([NotNull] this SpriteAtlas spriteAtlas, string secondaryTextureName);
132162
extern internal static void SetSecondaryColorSpace([NotNull] this SpriteAtlas spriteAtlas, string secondaryTextureName, bool srGB);
133163
extern internal static void DeleteSecondaryPlatformSettings([NotNull] this SpriteAtlas spriteAtlas, string secondaryTextureName);

Editor/Mono/2D/SpriteAtlas/SpriteAtlasImporter.bindings.cs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,41 @@ public sealed partial class SpriteAtlasImporter : AssetImporter
2424
extern public bool includeInBuild { get; set; }
2525
extern public SpriteAtlasPackingSettings packingSettings { get; set; }
2626
extern public SpriteAtlasTextureSettings textureSettings { get; set; }
27-
extern public void SetPlatformSettings(TextureImporterPlatformSettings src);
28-
extern public TextureImporterPlatformSettings GetPlatformSettings(string buildTarget);
27+
28+
[NativeName("SetPlatformSettings")]
29+
extern private void SetPlatformSettings_Internal(TextureImporterPlatformSettings src);
30+
public void SetPlatformSettings(TextureImporterPlatformSettings src)
31+
{
32+
src.name = TextureImporter.GetTexturePlatformSerializationName(src.name); // String may refer to a platform group: if != "Standalone", ensure it refers to a platform instead. E.g.: "iOS", not "iPhone".
33+
SetPlatformSettings_Internal(src);
34+
}
35+
36+
[NativeName("GetPlatformSettings")]
37+
extern private TextureImporterPlatformSettings GetPlatformSettings_Internal(string buildTarget);
38+
public TextureImporterPlatformSettings GetPlatformSettings(string buildTarget)
39+
{
40+
buildTarget = TextureImporter.GetTexturePlatformSerializationName(buildTarget); // String may refer to a platform group: if != "Standalone", ensure it refers to a platform instead. E.g.: "iOS", not "iPhone".
41+
return GetPlatformSettings_Internal(buildTarget);
42+
}
43+
2944
extern internal TextureFormat GetTextureFormat(BuildTarget target);
30-
extern internal TextureImporterPlatformSettings GetSecondaryPlatformSettings(string buildTarget, string secondaryTextureName);
31-
extern internal void SetSecondaryPlatformSettings(TextureImporterPlatformSettings src, string secondaryTextureName);
45+
46+
[NativeName("GetSecondaryPlatformSettings")]
47+
extern private TextureImporterPlatformSettings GetSecondaryPlatformSettings_Internal(string buildTarget, string secondaryTextureName);
48+
internal TextureImporterPlatformSettings GetSecondaryPlatformSettings(string buildTarget, string secondaryTextureName)
49+
{
50+
buildTarget = TextureImporter.GetTexturePlatformSerializationName(buildTarget); // String may refer to a platform group: if != "Standalone", ensure it refers to a platform instead. E.g.: "iOS", not "iPhone".
51+
return GetSecondaryPlatformSettings_Internal(buildTarget, secondaryTextureName);
52+
}
53+
54+
[NativeName("SetSecondaryPlatformSettings")]
55+
extern private void SetSecondaryPlatformSettings_Internal(TextureImporterPlatformSettings src, string secondaryTextureName);
56+
internal void SetSecondaryPlatformSettings(TextureImporterPlatformSettings src, string secondaryTextureName)
57+
{
58+
src.name = TextureImporter.GetTexturePlatformSerializationName(src.name); // String may refer to a platform group: if != "Standalone", ensure it refers to a platform instead. E.g.: "iOS", not "iPhone".
59+
SetSecondaryPlatformSettings_Internal(src, secondaryTextureName);
60+
}
61+
3262
extern internal bool GetSecondaryColorSpace(string secondaryTextureName);
3363
extern internal void SetSecondaryColorSpace(string secondaryTextureName, bool srGB);
3464
extern internal void DeleteSecondaryPlatformSettings(string secondaryTextureName);

Editor/Mono/Animation/AnimationUtility.bindings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ public static AnimationClip[] GetAnimationClips(GameObject gameObject)
130130
var extraClips = new List<AnimationClip>();
131131
clipSources[i].GetAnimationClips(extraClips);
132132

133-
allClips.AddRange(extraClips);
133+
allClips.Capacity = allClips.Count + extraClips.Count;
134+
foreach (var clip in extraClips)
135+
{
136+
if (clip != null)
137+
allClips.Add(clip);
138+
}
134139
}
135140

136141
return allClips.ToArray();

Editor/Mono/Animation/AnimationWindow/CurveEditorWindow.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ public enum NormalizationMode
4444

4545
[SerializeField]
4646
GUIView m_DelegateView;
47-
internal GUIView delegateView => m_DelegateView;
4847

4948
public const string CurveChangedCommand = "CurveChanged";
5049
public const string CurveChangeCompletedCommand = "CurveChangeCompleted";
5150

51+
// Watch out when accessing this, it will create a new curve editor window if none exists yet.
52+
// If you don't display the window (call Show()), it will cause an error when validating the layout
53+
// (e.g. when the user maximizes a window).
5254
public static CurveEditorWindow instance
5355
{
5456
get
@@ -100,6 +102,11 @@ public static Color color
100102
}
101103
}
102104

105+
internal static GUIView delegateView
106+
{
107+
get { return visible ? CurveEditorWindow.instance.m_DelegateView : null; }
108+
}
109+
103110
public static bool visible
104111
{
105112
get { return s_SharedCurveEditor != null; }

Editor/Mono/Animation/AnimatorController.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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 UnityEngine;
67
using System.IO;
78
using System.Collections.Generic;
@@ -305,14 +306,10 @@ public Motion GetStateEffectiveMotion(AnimatorState state)
305306

306307
public Motion GetStateEffectiveMotion(AnimatorState state, int layerIndex)
307308
{
308-
if (layers[layerIndex].syncedLayerIndex == -1)
309-
{
310-
return state.motion;
311-
}
312-
else
313-
{
314-
return layers[layerIndex].GetOverrideMotion(state);
315-
}
309+
if (layerIndex < 0 || layerIndex > layers.Length)
310+
return null;
311+
312+
return layers[layerIndex].syncedLayerIndex == -1 ? state.motion : layers[layerIndex].GetOverrideMotion(state);
316313
}
317314

318315
public void SetStateEffectiveBehaviours(AnimatorState state, int layerIndex, StateMachineBehaviour[] behaviours)
@@ -331,6 +328,9 @@ public void SetStateEffectiveBehaviours(AnimatorState state, int layerIndex, Sta
331328

332329
public StateMachineBehaviour[] GetStateEffectiveBehaviours(AnimatorState state, int layerIndex)
333330
{
331+
if (layerIndex < 0 || layerIndex > layers.Length)
332+
return Array.Empty<StateMachineBehaviour>();
333+
334334
return Internal_GetEffectiveBehaviours(state, layerIndex) as StateMachineBehaviour[];
335335
}
336336

Editor/Mono/Animation/StateMachine.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ public void RemoveCondition(AnimatorCondition condition)
100100
}
101101
}
102102

103-
103+
[HelpURL("StateMachineTransitions")]
104104
internal class AnimatorDefaultTransition : ScriptableObject
105105
{
106106
}
107107

108+
[HelpURL("class-State")]
108109
public partial class AnimatorState : Object
109110
{
110111
private PushUndoIfNeeded undoHandler = new PushUndoIfNeeded(true);
@@ -242,6 +243,7 @@ public int uniqueNameHash
242243
}
243244
}
244245

246+
[HelpURL("NestedStateMachines")]
245247
public partial class AnimatorStateMachine : Object
246248
{
247249
private PushUndoIfNeeded undoHandler = new PushUndoIfNeeded(true);

Editor/Mono/Annotation/AnnotationWindow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ private enum EnabledState
5656
const float k_WindowWidth = 270;
5757
const float k_ScrollBarWidth = 14;
5858
const float k_ListElementHeight = 18;
59-
const float k_JustClosedPeriod = 200;
6059
const float k_FrameWidth = 1f;
6160
float iconSize = 16;
6261
float gizmoRightAlign;
@@ -66,6 +65,8 @@ private enum EnabledState
6665

6766
static AnnotationWindow s_AnnotationWindow = null;
6867
static long s_LastClosedTime;
68+
const long k_JustClosedPeriod = 400;
69+
6970
static Styles m_Styles;
7071
List<GizmoInfo> m_RecentAnnotations;
7172
List<GizmoInfo> m_BuiltinAnnotations;

Editor/Mono/Annotation/LayerVisibilityWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public Styles()
3939
const float k_FrameWidth = 1f;
4040
const float k_ToggleSize = 17;
4141
const float k_SeparatorHeight = 6;
42-
const float k_JustClosedPeriod = 200;
4342
const string k_LayerVisible = "Show/Hide Layer";
4443
const string k_LayerPickable = "Toggle Pickable status this Layer. Non-Pickable items cannot be selected in the Scene View.";
4544

4645
private static LayerVisibilityWindow s_LayerVisibilityWindow;
4746
private static long s_LastClosedTime;
48-
private static Styles s_Styles;
47+
const long k_JustClosedPeriod = 400;
4948

49+
private static Styles s_Styles;
5050
private List<string> s_LayerNames;
5151
private List<int> s_LayerMasks;
5252
private int m_AllLayersMask;

Editor/Mono/Annotation/SceneRenderModeWindow.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ static class Styles
146146

147147
}
148148

149+
// Default CameraMode should be DrawCameraMode.GIContributorsReceivers
150+
internal static SceneView.CameraMode defaultCameraMode
151+
{
152+
get
153+
{
154+
var mode = Styles.sBuiltinCameraModes [3];
155+
if(mode.drawMode != DrawCameraMode.GIContributorsReceivers)
156+
Debug.LogError("Default Draw Camera mode should be set to DrawCameraMode.GIContributorsReceivers.");
157+
return mode;
158+
}
159+
}
160+
149161
private Dictionary<string, bool> foldoutStates = new Dictionary<string, bool>();
150162

151163
private float windowHeight

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Profiler")]
5353
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Rendering")]
5454
[assembly: InternalsVisibleTo("Unity.IntegrationTests.SceneVisibility")]
55+
[assembly: InternalsVisibleTo("Unity.IntegrationTests.ScriptCompilation")]
5556
[assembly: InternalsVisibleTo("Unity.IntegrationTests.ShortcutManager")]
5657
[assembly: InternalsVisibleTo("Unity.IntegrationTests.UIToolkit")]
5758
[assembly: InternalsVisibleTo("Unity.IntegrationTests.Framework.PackageManager")]

0 commit comments

Comments
 (0)