Skip to content

Commit f6dc11b

Browse files
author
Unity Technologies
committed
Unity 2018.1.0b6 C# reference source code
1 parent 57f4711 commit f6dc11b

Some content is hidden

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

43 files changed

+881
-562
lines changed

Editor/Mono/Annotation/SceneRenderModeWindow.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,23 @@ private float windowHeight
158158
{
159159
get
160160
{
161-
int headers = Styles.sBuiltinCameraModes.Where(mode => m_SceneView.IsCameraDrawModeEnabled(mode)).Select(mode => mode.section).Distinct().Count() +
162-
SceneView.userDefinedModes.Where(mode => m_SceneView.IsCameraDrawModeEnabled(mode)).Select(mode => mode.section).Distinct().Count();
163-
int modes = Styles.sBuiltinCameraModes.Count(mode => m_SceneView.IsCameraDrawModeEnabled(mode)) + SceneView.userDefinedModes.Count(mode => m_SceneView.IsCameraDrawModeEnabled(mode));
161+
int headers;
162+
int modes;
163+
164+
// TODO: This needs to be fixed and we need to find a way to dif. between disabled and unsupported
165+
if (GraphicsSettings.renderPipelineAsset != null)
166+
{
167+
// When using SRP, we completely hide disabled builtin modes, including headers
168+
headers = Styles.sBuiltinCameraModes.Where(mode => m_SceneView.IsCameraDrawModeEnabled(mode)).Select(mode => mode.section).Distinct().Count() +
169+
SceneView.userDefinedModes.Where(mode => m_SceneView.IsCameraDrawModeEnabled(mode)).Select(mode => mode.section).Distinct().Count();
170+
modes = Styles.sBuiltinCameraModes.Count(mode => m_SceneView.IsCameraDrawModeEnabled(mode)) + SceneView.userDefinedModes.Count(mode => m_SceneView.IsCameraDrawModeEnabled(mode));
171+
}
172+
else
173+
{
174+
headers = Styles.sBuiltinCameraModes.Select(mode => mode.section).Distinct().Count() + SceneView.userDefinedModes.Where(mode => m_SceneView.IsCameraDrawModeEnabled(mode)).Select(mode => mode.section).Distinct().Count();
175+
modes = Styles.sBuiltinCameraModes.Count() + SceneView.userDefinedModes.Count(mode => m_SceneView.IsCameraDrawModeEnabled(mode));
176+
}
177+
164178
int separators = headers - 2;
165179
return ((headers + modes) * EditorGUI.kSingleLineHeight) + (kSeparatorHeight * separators) + kShowLightmapResolutionHeight;
166180
}

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ internal static string ApiCompatibilityLevelToDotNetProfileArgument(ApiCompatibi
104104
return "net20";
105105

106106
case ApiCompatibilityLevel.NET_4_6:
107-
return "net45";
107+
return "unityjit";
108108

109109
case ApiCompatibilityLevel.NET_Standard_2_0:
110110
return "unityaot";
@@ -195,7 +195,7 @@ public void RunCompileAndLink()
195195
arguments.Add(string.Format("--map-file-parser=\"{0}\"", GetMapFileParserPath()));
196196
arguments.Add(string.Format("--generatedcppdir=\"{0}\"", Path.GetFullPath(GetCppOutputDirectoryInStagingArea())));
197197
if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6)
198-
arguments.Add("--dotnetprofile=\"net45\"");
198+
arguments.Add("--dotnetprofile=\"unityjit\"");
199199
if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_Standard_2_0)
200200
arguments.Add("--dotnetprofile=\"unityaot\"");
201201
Action<ProcessStartInfo> setupStartInfo = il2CppNativeCodeBuilder.SetupStartInfo;
@@ -287,7 +287,7 @@ private void ConvertPlayerDlltoCpp(ICollection<string> userAssemblies, string ou
287287

288288
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(m_PlatformProvider.target);
289289
if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6)
290-
arguments.Add("--dotnetprofile=\"net45\"");
290+
arguments.Add("--dotnetprofile=\"unityjit\"");
291291

292292
if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_Standard_2_0)
293293
arguments.Add("--dotnetprofile=\"unityaot\"");

Editor/Mono/EditorGUI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8111,6 +8111,8 @@ internal static Rect GetToggleRect(bool hasLabel, params GUILayoutOption[] optio
81118111

81128112
public class FadeGroupScope : GUI.Scope
81138113
{
8114+
// when using the FadeGroupScope, make sure to only show the content when 'visible' is set to true,
8115+
// otherwise only the hide animation will run, and then the content will be visible again.
81148116
public bool visible { get; protected set; }
81158117
float m_Value;
81168118

Editor/Mono/EditorHandles/ArcHandle.cs

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +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;
5+
using System.Collections.Generic;
66
using UnityEngine;
77

88
namespace UnityEditor.IMGUI.Controls
@@ -14,27 +14,49 @@ public class ArcHandle
1414

1515
static readonly float s_DefaultRadiusHandleSize = 0.03f;
1616

17-
static float DefaultAngleHandleSizeFunction(Vector3 position)
17+
static readonly Dictionary<int, Quaternion> s_MostRecentValidAngleHandleOrientations =
18+
new Dictionary<int, Quaternion>();
19+
20+
// only used inside of DefaultAngleHandleDrawFunction to look up and store the most recent valid orientation per handle
21+
// done so that DefaultAngleHandleDrawFunction can be a static method, which makes angleHandleDrawFunction more usable by sub-classes
22+
static int s_CurrentlyDrawingAngleHandleHash;
23+
24+
public static void DefaultAngleHandleDrawFunction(
25+
int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType
26+
)
1827
{
19-
return HandleUtility.GetHandleSize(position) * s_DefaultAngleHandleSize;
28+
Handles.DrawLine(Vector3.zero, position);
29+
30+
// draw a cylindrical "hammer head" to indicate the direction the handle will move
31+
Vector3 worldPosition = Handles.matrix.MultiplyPoint3x4(position);
32+
Vector3 normal = worldPosition - Handles.matrix.MultiplyPoint3x4(Vector3.zero);
33+
Vector3 tangent = Handles.matrix.MultiplyVector(Quaternion.AngleAxis(90f, Vector3.up) * position);
34+
Quaternion mostRecentValidOrientation;
35+
if (!s_MostRecentValidAngleHandleOrientations.TryGetValue(s_CurrentlyDrawingAngleHandleHash, out mostRecentValidOrientation))
36+
mostRecentValidOrientation = Quaternion.identity;
37+
rotation = Mathf.Approximately(tangent.sqrMagnitude, 0f) ?
38+
mostRecentValidOrientation : Quaternion.LookRotation(tangent, normal);
39+
s_MostRecentValidAngleHandleOrientations[s_CurrentlyDrawingAngleHandleHash] = rotation;
40+
Matrix4x4 matrix =
41+
Matrix4x4.TRS(worldPosition, rotation, (Vector3.one + Vector3.forward * s_DefaultAngleHandleSizeRatio));
42+
using (new Handles.DrawingScope(matrix))
43+
Handles.CylinderHandleCap(controlID, Vector3.zero, Quaternion.identity, size, eventType);
44+
s_CurrentlyDrawingAngleHandleHash = 0;
2045
}
2146

22-
static float DefaultRadiusHandleSizeFunction(Vector3 position)
47+
public static float DefaultAngleHandleSizeFunction(Vector3 position)
2348
{
24-
return HandleUtility.GetHandleSize(position) * s_DefaultRadiusHandleSize;
49+
return HandleUtility.GetHandleSize(position) * s_DefaultAngleHandleSize;
2550
}
2651

27-
static void DefaultRadiusHandleDrawFunction(
28-
int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType
29-
)
52+
public static float DefaultRadiusHandleSizeFunction(Vector3 position)
3053
{
31-
Handles.DotHandleCap(controlID, position, rotation, size, eventType);
54+
return HandleUtility.GetHandleSize(position) * s_DefaultRadiusHandleSize;
3255
}
3356

3457
private bool m_ControlIDsReserved = false;
3558
private int m_AngleHandleControlID;
3659
private int[] m_RadiusHandleControlIDs = new int[4];
37-
private Quaternion m_MostRecentValidAngleHandleOrientation = Quaternion.identity;
3860

3961
public float angle { get; set; }
4062

@@ -60,6 +82,15 @@ public ArcHandle()
6082
{
6183
radius = 1f;
6284
SetColorWithoutRadiusHandle(Color.white, 0.1f);
85+
angleHandleDrawFunction = DefaultAngleHandleDrawFunction;
86+
angleHandleSizeFunction = DefaultAngleHandleSizeFunction;
87+
radiusHandleDrawFunction = Handles.DotHandleCap;
88+
radiusHandleSizeFunction = DefaultRadiusHandleSizeFunction;
89+
}
90+
91+
~ArcHandle()
92+
{
93+
s_MostRecentValidAngleHandleOrientations.Remove(GetHashCode());
6394
}
6495

6596
public void SetColorWithoutRadiusHandle(Color color, float fillColorAlpha)
@@ -147,15 +178,13 @@ public void DrawHandle()
147178
Vector3 newPosition;
148179
EditorGUI.BeginChangeCheck();
149180
{
150-
float size = radiusHandleSizeFunction == null ?
151-
DefaultRadiusHandleSizeFunction(radiusHandlePosition) :
152-
radiusHandleSizeFunction(radiusHandlePosition);
181+
var size = radiusHandleSizeFunction == null ? 0f : radiusHandleSizeFunction(radiusHandlePosition);
153182
newPosition = Handles.Slider(
154183
m_RadiusHandleControlIDs[i],
155184
radiusHandlePosition,
156185
Vector3.forward,
157186
size,
158-
radiusHandleDrawFunction ?? DefaultRadiusHandleDrawFunction,
187+
radiusHandleDrawFunction,
159188
SnapSettings.move.z
160189
);
161190
}
@@ -171,21 +200,20 @@ public void DrawHandle()
171200
// draw angle handle last so it will always take precedence when overlapping a radius handle
172201
using (new Handles.DrawingScope(Handles.color * angleHandleColor))
173202
{
174-
if (Handles.color.a > 0f)
203+
if (Handles.color.a > 0f && angleHandleDrawFunction != null)
175204
{
176205
EditorGUI.BeginChangeCheck();
177206
{
178-
float size = angleHandleSizeFunction == null ?
179-
DefaultAngleHandleSizeFunction(angleHandlePosition) :
180-
angleHandleSizeFunction(angleHandlePosition);
207+
var size = angleHandleSizeFunction == null ? 0f : angleHandleSizeFunction(angleHandlePosition);
208+
s_CurrentlyDrawingAngleHandleHash = GetHashCode();
181209
angleHandlePosition = Handles.Slider2D(
182210
m_AngleHandleControlID,
183211
angleHandlePosition,
184212
Vector3.up,
185213
Vector3.forward,
186214
Vector3.right,
187215
size,
188-
angleHandleDrawFunction ?? DefaultAngleHandleDrawFunction,
216+
angleHandleDrawFunction,
189217
Vector2.zero
190218
);
191219
}
@@ -207,23 +235,5 @@ internal void GetControlIDs()
207235
m_RadiusHandleControlIDs[i] = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
208236
m_ControlIDsReserved = true;
209237
}
210-
211-
private void DefaultAngleHandleDrawFunction(
212-
int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType
213-
)
214-
{
215-
Handles.DrawLine(Vector3.zero, position);
216-
217-
// draw a cylindrical "hammer head" to indicate the direction the handle will move
218-
Vector3 worldPosition = Handles.matrix.MultiplyPoint3x4(position);
219-
Vector3 normal = worldPosition - Handles.matrix.MultiplyPoint3x4(Vector3.zero);
220-
Vector3 tangent = Handles.matrix.MultiplyVector(Quaternion.AngleAxis(90f, Vector3.up) * position);
221-
m_MostRecentValidAngleHandleOrientation = rotation = tangent.sqrMagnitude == 0f ?
222-
m_MostRecentValidAngleHandleOrientation : Quaternion.LookRotation(tangent, normal);
223-
Matrix4x4 matrix =
224-
Matrix4x4.TRS(worldPosition, rotation, (Vector3.one + Vector3.forward * s_DefaultAngleHandleSizeRatio));
225-
using (new Handles.DrawingScope(matrix))
226-
Handles.CylinderHandleCap(controlID, Vector3.zero, Quaternion.identity, size, eventType);
227-
}
228238
}
229239
}

Editor/Mono/EditorHandles/BoundsHandle/PrimitiveBoundsHandle.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal static GUIContent editModeButton
4848
}
4949
private static GUIContent s_EditModeButton;
5050

51-
private static float DefaultMidpointHandleSizeFunction(Vector3 position)
51+
public static float DefaultMidpointHandleSizeFunction(Vector3 position)
5252
{
5353
return HandleUtility.GetHandleSize(position) * s_DefaultMidpointHandleSize;
5454
}
@@ -81,6 +81,8 @@ public PrimitiveBoundsHandle()
8181
handleColor = Color.white;
8282
wireframeColor = Color.white;
8383
axes = Axes.X | Axes.Y | Axes.Z;
84+
midpointHandleDrawFunction = Handles.DotHandleCap;
85+
midpointHandleSizeFunction = DefaultMidpointHandleSizeFunction;
8486
}
8587

8688
public void SetColor(Color color)
@@ -272,14 +274,15 @@ private Vector3 MidpointHandle(int id, Vector3 localPos, Vector3 localTangent, V
272274

273275
AdjustMidpointHandleColor(localPos, localTangent, localBinormal, isCameraInsideBox);
274276

275-
if (Handles.color.a > 0f)
277+
if (Handles.color.a > 0f && midpointHandleDrawFunction != null)
276278
{
277279
Vector3 localDir = Vector3.Cross(localTangent, localBinormal).normalized;
278280

279-
var drawFunc = midpointHandleDrawFunction ?? Handles.DotHandleCap;
280-
var sizeFunc = midpointHandleSizeFunction ?? DefaultMidpointHandleSizeFunction;
281+
var size = midpointHandleSizeFunction == null ? 0f : midpointHandleSizeFunction(localPos);
281282

282-
localPos = UnityEditorInternal.Slider1D.Do(id, localPos, localDir, sizeFunc(localPos), drawFunc, SnapSettings.scale);
283+
localPos = UnityEditorInternal.Slider1D.Do(
284+
id, localPos, localDir, size, midpointHandleDrawFunction, SnapSettings.scale
285+
);
283286
}
284287

285288
Handles.color = oldColor;

Editor/Mono/Inspector/CameraEditor.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,10 @@ public override void OnInspectorGUI()
450450

451451
settings.DrawClearFlags();
452452

453-
using (new EditorGUILayout.FadeGroupScope(m_ShowBGColorOptions.faded))
453+
if (EditorGUILayout.BeginFadeGroup(m_ShowBGColorOptions.faded))
454454
settings.DrawBackgroundColor();
455+
EditorGUILayout.EndFadeGroup();
456+
455457
settings.DrawCullingMask();
456458

457459
EditorGUILayout.Space();
@@ -480,8 +482,9 @@ public override void OnInspectorGUI()
480482
settings.DrawVR();
481483
settings.DrawMultiDisplay();
482484

483-
using (new EditorGUILayout.FadeGroupScope(m_ShowTargetEyeOption.faded))
485+
if (EditorGUILayout.BeginFadeGroup(m_ShowTargetEyeOption.faded))
484486
settings.DrawTargetEye();
487+
EditorGUILayout.EndFadeGroup();
485488

486489
DepthTextureModeGUI();
487490
CommandBufferGUI();
@@ -563,7 +566,7 @@ public virtual void OnOverlayGUI(Object target, SceneView sceneView)
563566
}
564567

565568
var previewTexture = GetPreviewTextureWithSize((int)cameraRect.width, (int)cameraRect.height);
566-
previewTexture.antiAliasing = QualitySettings.antiAliasing;
569+
previewTexture.antiAliasing = Mathf.Max(1, QualitySettings.antiAliasing);
567570
previewCamera.targetTexture = previewTexture;
568571
previewCamera.pixelRect = new Rect(0, 0, cameraRect.width, cameraRect.height);
569572

Editor/Mono/Inspector/HingeJoint2DEditor.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ internal override Bounds GetWorldBoundsOfTarget(UnityObject targetObject)
6666
return bounds;
6767
}
6868

69-
private void NonEditableHandleDrawFunction(
70-
int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType
71-
)
72-
{
73-
}
74-
7569
private static readonly Quaternion s_RightHandedHandleOrientationOffset =
7670
Quaternion.AngleAxis(180f, Vector3.right) * Quaternion.AngleAxis(90f, Vector3.up);
7771
private static readonly Quaternion s_LeftHandedHandleOrientationOffset =
@@ -96,9 +90,9 @@ private void NonEditableHandleDrawFunction(
9690
// only display control handles on manipulator if in edit mode
9791
var editMode = EditMode.editMode == EditMode.SceneViewEditMode.JointAngularLimits && EditMode.IsOwner(this);
9892
if (editMode)
99-
m_AngularLimitHandle.angleHandleDrawFunction = null;
93+
m_AngularLimitHandle.angleHandleDrawFunction = ArcHandle.DefaultAngleHandleDrawFunction;
10094
else
101-
m_AngularLimitHandle.angleHandleDrawFunction = NonEditableHandleDrawFunction;
95+
m_AngularLimitHandle.angleHandleDrawFunction = null;
10296

10397
// to enhance usability, orient the manipulator to best illustrate its affects on the dynamic body in the system
10498
var dynamicBody = hingeJoint2D.attachedRigidbody;

Editor/Mono/Inspector/InspectorWindow.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,16 +1003,6 @@ protected void AssignAssetEditor(Editor[] editors)
10031003
if (editors.Length > 1 && editors[0] is AssetImporterEditor)
10041004
{
10051005
(editors[0] as AssetImporterEditor).assetEditor = editors[1];
1006-
// if we have an asset editor but no target, it's likely the asset was just imported and we lost the target
1007-
// get the target back from the serialized object for all editors
1008-
// (dealing with multiple editors when a GameObject is involved)
1009-
for (int i = 0; i < editors.Length; i++)
1010-
{
1011-
if (editors[i].target == null)
1012-
{
1013-
editors[i].InternalSetTargets(editors[i].serializedObject.targetObjects);
1014-
}
1015-
}
10161006
}
10171007
}
10181008

0 commit comments

Comments
 (0)