Skip to content

Commit e94d025

Browse files
author
Unity Technologies
committed
Unity 2019.1.0a9 C# reference source code
1 parent 7a338a1 commit e94d025

File tree

180 files changed

+3499
-1745
lines changed

Some content is hidden

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

180 files changed

+3499
-1745
lines changed

Editor/Mono/2D/SpriteEditorModule/SpriteEditorData.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ internal SpriteDataExt(SerializedObject so)
4141

4242
var guidSP = so.FindProperty("m_SpriteSheet.m_SpriteID");
4343
spriteID = new GUID(guidSP.stringValue);
44+
45+
internalID = so.FindProperty("m_SpriteSheet.m_InternalID").longValue;
4446
}
4547

4648
internal SpriteDataExt(SerializedProperty sp)
@@ -52,6 +54,7 @@ internal SpriteDataExt(SerializedProperty sp)
5254
pivot = SpriteEditorUtility.GetPivotValue(alignment, sp.FindPropertyRelative("m_Pivot").vector2Value);
5355
tessellationDetail = sp.FindPropertyRelative("m_TessellationDetail").floatValue;
5456
spriteID = new GUID(sp.FindPropertyRelative("m_SpriteID").stringValue);
57+
internalID = sp.FindPropertyRelative("m_InternalID").longValue;
5558
}
5659

5760
internal SpriteDataExt(SpriteRect sr)
@@ -62,6 +65,7 @@ internal SpriteDataExt(SpriteRect sr)
6265
tessellationDetail = 0;
6366
rect = sr.rect;
6467
spriteID = sr.spriteID;
68+
internalID = sr.internalID;
6569
alignment = sr.alignment;
6670
pivot = sr.pivot;
6771
spriteOutline = new List<Vector2[]>();
@@ -79,6 +83,7 @@ public void Apply(SerializedObject so)
7983
so.FindProperty("m_SpritePivot").vector2Value = pivot;
8084
so.FindProperty("m_SpriteTessellationDetail").floatValue = tessellationDetail;
8185
so.FindProperty("m_SpriteSheet.m_SpriteID").stringValue = spriteID.ToString();
86+
so.FindProperty("m_SpriteSheet.m_InternalID").longValue = internalID;
8287

8388
var sp = so.FindProperty("m_SpriteSheet");
8489
if (spriteBone != null)
@@ -100,6 +105,13 @@ public void Apply(SerializedProperty sp)
100105
sp.FindPropertyRelative("m_Pivot").vector2Value = pivot;
101106
sp.FindPropertyRelative("m_TessellationDetail").floatValue = tessellationDetail;
102107
sp.FindPropertyRelative("m_SpriteID").stringValue = spriteID.ToString();
108+
if (internalID == 0L)
109+
{
110+
UnityType spriteType = UnityType.FindTypeByName("Sprite");
111+
internalID = ImportSettingInternalID.MakeInternalID(sp.serializedObject, spriteType, name);
112+
}
113+
114+
sp.FindPropertyRelative("m_InternalID").longValue = internalID;
103115

104116
if (spriteBone != null)
105117
SpriteBoneDataTransfer.Apply(sp, spriteBone);
@@ -119,6 +131,7 @@ public void CopyFromSpriteRect(SpriteRect spriteRect)
119131
pivot = spriteRect.pivot;
120132
rect = spriteRect.rect;
121133
spriteID = spriteRect.spriteID;
134+
internalID = spriteRect.internalID;
122135
}
123136
}
124137
}

Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ private SpriteRect AddSprite(Rect rect, int alignment, Vector2 pivot, int collid
218218
spriteRect.name = name;
219219
spriteRect.originalName = spriteRect.name;
220220
spriteRect.border = border;
221+
spriteRect.internalID = 0L;
222+
221223
spriteEditor.SetDataModified();
222224

223225
m_RectsCache.spriteRects.Add(spriteRect);

Editor/Mono/2D/SpriteEditorModule/SpriteFrameModule/SpriteFrameModuleBase.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,16 @@ public override bool ApplyRevert(bool apply)
101101
}
102102
var so = new SerializedObject(m_SpriteDataProvider.targetObject);
103103
if (oldNames.Count > 0)
104-
PatchImportSettingRecycleID.PatchMultiple(so, 213, oldNames.ToArray(), newNames.ToArray());
104+
{
105+
AssetImporter assetImporter = m_SpriteDataProvider.targetObject as AssetImporter;
106+
107+
if (assetImporter != null)
108+
{
109+
UnityType spriteType = UnityType.FindTypeByName("Sprite");
110+
assetImporter.RenameSubAssets(spriteType.persistentTypeID, oldNames.ToArray(), newNames.ToArray());
111+
}
112+
}
113+
105114
so.ApplyModifiedPropertiesWithoutUndo();
106115
}
107116
m_SpriteDataProvider.SetSpriteRects(m_RectsCache?.spriteRects.ToArray());
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using System;
6+
using UnityEngine;
7+
8+
namespace UnityEditor
9+
{
10+
class SceneViewCameraWindow : PopupWindowContent
11+
{
12+
static class Styles
13+
{
14+
static bool s_Initialized;
15+
public static GUIStyle settingsArea;
16+
17+
public static void Init()
18+
{
19+
if (s_Initialized)
20+
return;
21+
22+
s_Initialized = true;
23+
24+
settingsArea = new GUIStyle()
25+
{
26+
padding = new RectOffset(4, 4, 4, 4),
27+
};
28+
}
29+
}
30+
31+
readonly SceneView m_SceneView;
32+
33+
GUIContent m_CameraSpeedSliderContent;
34+
GUIContent[] m_CameraSpeedMinMax;
35+
GUIContent m_FieldOfView;
36+
37+
const int k_FieldCount = 8;
38+
const int k_WindowWidth = 280;
39+
const int k_WindowHeight = ((int)EditorGUI.kSingleLineHeight) * k_FieldCount + kFrameWidth * 2;
40+
const int kFrameWidth = 10;
41+
const float k_PrefixLabelWidth = 100f;
42+
const float kMinMaxSpeedLabelWidth = 26f;
43+
const float k_NearClipMin = .01f;
44+
45+
float[] m_Vector2Floats = { 0, 0 };
46+
47+
public override Vector2 GetWindowSize()
48+
{
49+
return new Vector2(k_WindowWidth, k_WindowHeight);
50+
}
51+
52+
public SceneViewCameraWindow(SceneView sceneView)
53+
{
54+
m_SceneView = sceneView;
55+
56+
m_CameraSpeedSliderContent = EditorGUIUtility.TrTextContent("Speed", "The current speed of the camera in the Scene view.");
57+
m_CameraSpeedMinMax = new GUIContent[]
58+
{
59+
EditorGUIUtility.TrTextContent("Min", "The minimum speed of the camera in the Scene view. Valid values are between [0.01, 98]."),
60+
EditorGUIUtility.TrTextContent("Max", "The maximum speed of the camera in the Scene view. Valid values are between [0.02, 99].")
61+
};
62+
m_FieldOfView = EditorGUIUtility.TrTextContent("Field of View", "The height of the Camera's view angle. Measured in degrees vertically, or along the local Y axis.");
63+
}
64+
65+
public override void OnGUI(Rect rect)
66+
{
67+
if (m_SceneView == null || m_SceneView.sceneViewState == null)
68+
return;
69+
70+
Draw(rect);
71+
72+
// Escape closes the window
73+
if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
74+
{
75+
editorWindow.Close();
76+
GUIUtility.ExitGUI();
77+
}
78+
}
79+
80+
private void Draw(Rect rect)
81+
{
82+
var settings = m_SceneView.sceneViewCameraSettings;
83+
Styles.Init();
84+
85+
const int k_SettingsIconPad = 2;
86+
Vector2 settingsSize = EditorStyles.iconButton.CalcSize(EditorGUI.GUIContents.titleSettingsIcon);
87+
Rect settingsRect = new Rect(rect.xMax - Styles.settingsArea.padding.right - k_SettingsIconPad - settingsSize.x, Styles.settingsArea.padding.top + k_SettingsIconPad, settingsSize.x, settingsSize.y);
88+
89+
if (GUI.Button(settingsRect, EditorGUI.GUIContents.titleSettingsIcon, EditorStyles.iconButton))
90+
ShowContextMenu();
91+
92+
GUILayout.BeginArea(rect, Styles.settingsArea);
93+
94+
EditorGUI.BeginChangeCheck();
95+
96+
EditorGUIUtility.labelWidth = k_PrefixLabelWidth;
97+
98+
GUILayout.Label("Camera", EditorStyles.boldLabel);
99+
100+
// fov isn't applicable in orthographic mode, and orthographic size is controlled by the user zoom
101+
using (new EditorGUI.DisabledScope(m_SceneView.orthographic))
102+
{
103+
settings.fieldOfView = EditorGUILayout.Slider(m_FieldOfView, settings.fieldOfView, 4f, 179f);
104+
}
105+
106+
107+
float near = settings.nearClip, far = settings.farClip;
108+
ClipPlanesField(EditorGUI.s_ClipingPlanesLabel, ref near, ref far, EditorGUI.kNearFarLabelsWidth);
109+
settings.nearClip = near;
110+
settings.farClip = far;
111+
112+
settings.nearClip = Mathf.Max(k_NearClipMin, settings.nearClip);
113+
114+
if (settings.nearClip > settings.farClip)
115+
settings.farClip = settings.nearClip + k_NearClipMin;
116+
117+
if (EditorGUI.EndChangeCheck())
118+
m_SceneView.Repaint();
119+
120+
GUILayout.Label("Navigation", EditorStyles.boldLabel);
121+
122+
settings.speed = EditorGUILayout.Slider(m_CameraSpeedSliderContent, settings.speed, settings.speedMin, settings.speedMax);
123+
124+
EditorGUI.BeginChangeCheck();
125+
126+
m_Vector2Floats[0] = settings.speedMin;
127+
m_Vector2Floats[1] = settings.speedMax;
128+
129+
GUILayout.BeginHorizontal();
130+
GUILayout.Space(EditorGUIUtility.labelWidth);
131+
Rect r = EditorGUILayout.GetControlRect(false, EditorGUI.kSingleLineHeight, EditorStyles.numberField);
132+
EditorGUI.MultiFloatField(r, m_CameraSpeedMinMax, m_Vector2Floats, kMinMaxSpeedLabelWidth);
133+
GUILayout.EndHorizontal();
134+
135+
if (EditorGUI.EndChangeCheck())
136+
settings.SetSpeedMinMax(m_Vector2Floats);
137+
138+
EditorGUIUtility.labelWidth = 0f;
139+
140+
GUILayout.EndArea();
141+
}
142+
143+
internal static void ClipPlanesField(GUIContent label, ref float near, ref float far, float propertyLabelsWidth, params GUILayoutOption[] options)
144+
{
145+
bool hasLabel = EditorGUI.LabelHasContent(label);
146+
const float height = EditorGUI.kSingleLineHeight * 2 + EditorGUI.kVerticalSpacingMultiField;
147+
Rect r = EditorGUILayout.GetControlRect(hasLabel, height, EditorStyles.numberField, options);
148+
149+
Rect fieldPosition = EditorGUI.PrefixLabel(r, label);
150+
fieldPosition.height = EditorGUI.kSingleLineHeight;
151+
152+
float oldLabelWidth = EditorGUIUtility.labelWidth;
153+
int oldIndentLevel = EditorGUI.indentLevel;
154+
155+
EditorGUIUtility.labelWidth = propertyLabelsWidth;
156+
EditorGUI.indentLevel = 0;
157+
158+
near = EditorGUI.FloatField(fieldPosition, EditorGUI.s_NearAndFarLabels[0], near);
159+
fieldPosition.y += EditorGUI.kSingleLineHeight + EditorGUI.kVerticalSpacingMultiField;
160+
far = EditorGUI.FloatField(fieldPosition, EditorGUI.s_NearAndFarLabels[1], far);
161+
162+
EditorGUI.indentLevel = oldIndentLevel;
163+
EditorGUIUtility.labelWidth = oldLabelWidth;
164+
}
165+
166+
void ShowContextMenu()
167+
{
168+
var menu = new GenericMenu();
169+
menu.AddItem(GUIContent.Temp("Reset"), false, Reset);
170+
menu.ShowAsContext();
171+
}
172+
173+
void Reset()
174+
{
175+
m_SceneView.ResetSceneViewCameraSettings();
176+
m_SceneView.Repaint();
177+
}
178+
}
179+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using System;
6+
using UnityEngine;
7+
8+
namespace UnityEditor
9+
{
10+
class SceneViewSettingsProvider : SettingsProvider
11+
{
12+
class Styles
13+
{
14+
static bool s_Initialized;
15+
16+
public static GUIContent cameraMovementEasingEnabled = new GUIContent("Camera Easing", "Check this to enable camera movement easing. This makes the Camera ease in when it starts moving, and ease out when it stops.");
17+
public static GUIContent cameraMovementEasingDuration = new GUIContent("Camera Easing Duration", "How long it takes for the Camera speed to accelerate to full speed. Measured in seconds.");
18+
19+
public static GUIStyle settings;
20+
21+
public static void Init()
22+
{
23+
if (s_Initialized)
24+
return;
25+
26+
s_Initialized = true;
27+
28+
settings = new GUIStyle()
29+
{
30+
margin = new RectOffset(8, 4, 4, 4)
31+
};
32+
}
33+
}
34+
35+
[SettingsProvider]
36+
static SettingsProvider CreateSceneViewSettingsProvider()
37+
{
38+
return new SceneViewSettingsProvider("Preferences/Scene View");
39+
}
40+
41+
public SceneViewSettingsProvider(string path, SettingsScope scopes = SettingsScope.User)
42+
: base(path, scopes)
43+
{
44+
PopulateSearchKeywordsFromGUIContentProperties<Styles>();
45+
}
46+
47+
public override void OnGUI(string searchContext)
48+
{
49+
base.OnGUI(searchContext);
50+
Styles.Init();
51+
var searching = !string.IsNullOrEmpty(searchContext);
52+
53+
GUILayout.BeginVertical(Styles.settings, GUILayout.MaxWidth(SettingsWindow.s_DefaultLayoutMaxWidth));
54+
55+
if (!searching)
56+
GUILayout.Label("Navigation", EditorStyles.boldLabel);
57+
58+
if (!searching || SearchUtils.MatchSearch(searchContext, Styles.cameraMovementEasingEnabled.text))
59+
SceneViewMotion.movementEasingEnabled = EditorGUILayout.Toggle(
60+
Styles.cameraMovementEasingEnabled,
61+
SceneViewMotion.movementEasingEnabled);
62+
63+
using (new EditorGUI.DisabledScope(!SceneViewMotion.movementEasingEnabled))
64+
{
65+
if (!searching || SearchUtils.MatchSearch(searchContext, Styles.cameraMovementEasingDuration.text))
66+
SceneViewMotion.movementEasingDuration = EditorGUILayout.Slider(Styles.cameraMovementEasingDuration, SceneViewMotion.movementEasingDuration, 0.001f, 3f);
67+
}
68+
69+
GUILayout.EndVertical();
70+
}
71+
}
72+
}

Editor/Mono/AssetPipeline/AssetImporter.bindings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,16 @@ public void SaveAndReimport()
105105
[FreeFunction("AssetImporterBindings::LocalFileIDToClassID")]
106106
extern internal static int LocalFileIDToClassID(long fileId);
107107

108+
[FreeFunction("AssetImporterBindings::MakeLocalFileIDWithHash")]
109+
extern internal static long MakeLocalFileIDWithHash(int persistentTypeId, string name, long offset);
110+
extern internal long MakeInternalID(int persistentTypeId, string name);
111+
108112
extern public void AddRemap(SourceAssetIdentifier identifier, Object externalObject);
109113

110114
extern public bool RemoveRemap(SourceAssetIdentifier identifier);
111115

116+
extern internal void RenameSubAssets(int peristentTypeId, string[] oldNames, string[] newNames);
117+
112118
[FreeFunction("AssetImporterBindings::GetIdentifiers")]
113119
extern private static SourceAssetIdentifier[] GetIdentifiers(AssetImporter self);
114120
[FreeFunction("AssetImporterBindings::GetExternalObjects")]
@@ -134,5 +140,8 @@ public Dictionary<SourceAssetIdentifier, Object> GetExternalObjectMap()
134140

135141
[FreeFunction("AssetImporterBindings::RegisterImporter")]
136142
extern internal static void RegisterImporter(Type importer, int importerVersion, int queuePos, string fileExt, bool supportsImportDependencyHinting);
143+
144+
[FreeFunction("AssetImporterBindings::SupportsRemappedAssetType", HasExplicitThis = true, IsThreadSafe = true)]
145+
public extern bool SupportsRemappedAssetType(Type type);
137146
}
138147
}

Editor/Mono/AssetPipeline/BumpMapSettings.bindings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ internal class BumpMapSettings
1515

1616
public static extern void PerformBumpMapCheck(Material material);
1717
}
18+
19+
public static class MaterialEditorExtensions
20+
{
21+
public static void PerformBumpMapCheck(this Material material)
22+
{
23+
BumpMapSettings.PerformBumpMapCheck(material);
24+
}
25+
}
1826
}

Editor/Mono/EditorGUI.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ public sealed partial class EditorGUI
126126
private static readonly GUIContent s_SizeLabel = EditorGUIUtility.TrTextContent("Size");
127127
internal static GUIContent s_PleasePressAKey = EditorGUIUtility.TrTextContent("[Please press a key]");
128128

129-
internal static readonly GUIContent s_ClipingPlanesLabel = EditorGUIUtility.TrTextContent("Clipping Planes", "Distances from the camera to start and stop rendering.");
130-
internal static readonly GUIContent[] s_NearAndFarLabels = { EditorGUIUtility.TrTextContent("Near", "The closest point relative to the camera that drawing will occur."), EditorGUIUtility.TrTextContent("Far", "The furthest point relative to the camera that drawing will occur.\n") };
129+
internal static readonly GUIContent s_ClipingPlanesLabel = EditorGUIUtility.TrTextContent("Clipping Planes", "The distances from the Camera where rendering starts and stops.");
130+
internal static readonly GUIContent[] s_NearAndFarLabels = { EditorGUIUtility.TrTextContent("Near", "The closest point to the Camera where drawing occurs."), EditorGUIUtility.TrTextContent("Far", "The furthest point from the Camera that drawing occurs.") };
131131
internal const float kNearFarLabelsWidth = 35f;
132132

133133
private static int s_ColorPickID;
@@ -2232,7 +2232,7 @@ internal static long LongFieldInternal(Rect position, GUIContent label, long val
22322232
public static float Slider(Rect position, float value, float leftValue, float rightValue)
22332233
{
22342234
int id = GUIUtility.GetControlID(s_SliderHash, FocusType.Keyboard, position);
2235-
return DoSlider(IndentedRect(position), EditorGUIUtility.DragZoneRect(position), id, value, leftValue, rightValue, kFloatFieldFormatString);
2235+
return DoSlider(IndentedRect(position), EditorGUIUtility.DragZoneRect(position, false), id, value, leftValue, rightValue, kFloatFieldFormatString);
22362236
}
22372237

22382238
public static float Slider(Rect position, string label, float value, float leftValue, float rightValue)

0 commit comments

Comments
 (0)