Skip to content

Commit 90fef38

Browse files
author
Unity Technologies
committed
Unity 2017.1.0b7 C# reference source code
1 parent 903a96f commit 90fef38

33 files changed

+520
-196
lines changed

Editor/Mono/BuildPipeline/BuildUtils.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,18 @@ private static void RunProgram(Program p, string exe, string args, string workin
113113
stopwatch.Stop();
114114
Console.WriteLine("{0} exited after {1} ms.", exe, stopwatch.ElapsedMilliseconds);
115115

116+
IEnumerable<CompilerMessage> messages = null;
117+
if (parser != null)
118+
{
119+
var errorOutput = p.GetErrorOutput();
120+
var standardOutput = p.GetStandardOutput();
121+
messages = parser.Parse(errorOutput, standardOutput, true);
122+
}
123+
116124
if (p.ExitCode != 0)
117125
{
118-
if (parser != null)
126+
if (messages != null)
119127
{
120-
var errorOutput = p.GetErrorOutput();
121-
var standardOutput = p.GetStandardOutput();
122-
var messages = parser.Parse(errorOutput, standardOutput, true);
123-
124128
foreach (var message in messages)
125129
Debug.LogPlayerBuildError(message.message, message.file, message.line, message.column);
126130
}
@@ -129,6 +133,14 @@ private static void RunProgram(Program p, string exe, string args, string workin
129133

130134
throw new Exception(string.Format("{0} did not run properly!", exe));
131135
}
136+
else
137+
{
138+
if (messages != null)
139+
{
140+
foreach (var message in messages)
141+
Console.WriteLine(message.message + " - " + message.file + " - " + message.line + " - " + message.column);
142+
}
143+
}
132144
}
133145
}
134146
}

Editor/Mono/Collab/AssetAccess.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,31 @@ public static bool TryGetAssetGUIDFromObject(UnityEngine.Object objectWithGUID,
3737
return success;
3838
}
3939

40+
// Attempts to retrieve the Asset corresponding to the given GUID.
41+
// Failure: returns false and the given 'asset' is set to null.
42+
// Success: returns true and updates 'asset'.
43+
public static bool TryGetAssetFromGUID(string assetGUID, out UnityEngine.Object asset)
44+
{
45+
if (assetGUID == null)
46+
{
47+
throw new ArgumentNullException("assetGUID");
48+
}
49+
50+
bool success = false;
51+
string objectPath = AssetDatabase.GUIDToAssetPath(assetGUID);
52+
53+
if (objectPath == null)
54+
{
55+
asset = null;
56+
}
57+
else
58+
{
59+
asset = AssetDatabase.LoadMainAssetAtPath(objectPath);
60+
success = (asset != null);
61+
}
62+
return success;
63+
}
64+
4065
// Expects the given 'gameObject' to have a 'PrefabType' which
4166
// is either an 'instance' or straight prefab.
4267
// Failure: assigns empty string to 'assetGUID', returns false.

Editor/Mono/Collab/CollabTesting.cs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@ namespace UnityEditor.Collaboration
1010
{
1111
internal class CollabTesting
1212
{
13-
private static IEnumerator<bool> _enumerator = null;
13+
[Flags]
14+
public enum AsyncState
15+
{
16+
NotWaiting = 0,
17+
WaitForJobComplete,
18+
WaitForAssetUpdate,
19+
}
20+
21+
private static IEnumerator<AsyncState> _enumerator = null;
1422
private static Action _runAfter = null;
23+
private static AsyncState _nextState = AsyncState.NotWaiting;
1524

16-
public static Func<IEnumerable<bool>> Tick
25+
public static Func<IEnumerable<AsyncState>> Tick
1726
{
1827
set { _enumerator = value().GetEnumerator(); }
1928
}
@@ -30,7 +39,22 @@ public static bool IsRunning
3039

3140
public static void OnCompleteJob()
3241
{
33-
Execute();
42+
if ((_nextState & AsyncState.WaitForJobComplete) == 0)
43+
return;
44+
45+
_nextState &= ~AsyncState.WaitForJobComplete;
46+
if (_nextState == AsyncState.NotWaiting)
47+
Execute();
48+
}
49+
50+
public static void OnAssetUpdate()
51+
{
52+
if ((_nextState & AsyncState.WaitForAssetUpdate) == 0)
53+
return;
54+
55+
_nextState &= ~AsyncState.WaitForAssetUpdate;
56+
if (_nextState == AsyncState.NotWaiting)
57+
Execute();
3458
}
3559

3660
public static void Execute()
@@ -45,6 +69,8 @@ public static void Execute()
4569
{
4670
if (!_enumerator.MoveNext())
4771
End();
72+
else
73+
_nextState = _enumerator.Current;
4874
}
4975
catch (Exception)
5076
{

Editor/Mono/Collab/Softlocks/SoftlockData.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,29 @@ public static bool AllowsSoftLocks(UnityEngine.Object unityObject)
4444
}
4545
else
4646
{
47-
PrefabType prefabType = PrefabUtility.GetPrefabType(unityObject);
48-
if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.Prefab)
49-
{
50-
supportsSoftLocks = true;
51-
}
47+
supportsSoftLocks = IsPrefab(unityObject);
5248
}
5349
return supportsSoftLocks;
5450
}
5551

52+
public static bool IsPrefab(UnityEngine.Object unityObject)
53+
{
54+
PrefabType prefabType = PrefabUtility.GetPrefabType(unityObject);
55+
bool isPrefab = (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.Prefab);
56+
return isPrefab;
57+
}
58+
59+
public static bool IsPrefab(string assetGUID)
60+
{
61+
bool isPrefab = false;
62+
UnityEngine.Object unityObject;
63+
if (AssetAccess.TryGetAssetFromGUID(assetGUID, out unityObject))
64+
{
65+
isPrefab = IsPrefab(unityObject);
66+
}
67+
return isPrefab;
68+
}
69+
5670
private static bool TryHasSoftLocks(Scene scene, out bool hasSoftLocks)
5771
{
5872
string assetGUID = AssetDatabase.AssetPathToGUID(scene.path);

Editor/Mono/Collab/Softlocks/SoftlockViewController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ internal class SoftlockViewController
2525
// a repaint when softlock data changes.
2626
private SoftlockViewController.Cache m_Cache = null;
2727

28-
private const string k_TooltipHeader = "Currently Editing:";
28+
private const string k_TooltipHeader = "Unpublished changes by:";
29+
private const string k_TooltipPrefabHeader = "Unpublished Prefab changes by:";
2930
private const string k_TooltipNamePrefix = " \n \u2022 "; // u2022 displays a • (bullet point)
3031

3132
private SoftlockViewController() {}
@@ -285,7 +286,8 @@ private string GetTooltip(string assetGUID)
285286
if (!m_Cache.TryGetTooltipForGUID(assetGUID, out formattedText))
286287
{
287288
List<string> softLockNames = SoftLockUIData.GetLocksNamesOnAsset(assetGUID);
288-
formattedText = k_TooltipHeader;
289+
string tooltipHeaderText = (SoftLockData.IsPrefab(assetGUID) ? k_TooltipPrefabHeader : k_TooltipHeader);
290+
formattedText = tooltipHeaderText;
289291

290292
foreach (string name in softLockNames)
291293
{

Editor/Mono/EditorHandles/ArcHandle.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using UnityEngine;
7-
using UnityRandom = UnityEngine.Random;
87

98
namespace UnityEditor.IMGUI.Controls
109
{
@@ -77,7 +76,7 @@ static void DefaultRadiusHandleDrawFunction(
7776

7877
public ArcHandle() : this(0)
7978
{
80-
m_ControlIDHint = UnityRandom.Range(Int32.MinValue, Int32.MaxValue);
79+
m_ControlIDHint = GetHashCode();
8180
}
8281

8382
public ArcHandle(int controlIDHint)

Editor/Mono/EditorHandles/BoundsHandle/PrimitiveBoundsHandle.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,8 @@ public void DrawHandle()
9797
}
9898

9999
// wireframe (before handles so handles are rendered top most)
100-
Color oldColor = Handles.color;
101-
Handles.color *= wireframeColor;
102-
if (Handles.color.a > 0f)
103-
{
100+
using (new Handles.DrawingScope(Handles.color * wireframeColor))
104101
DrawWireframe();
105-
}
106102

107103
// unless holding alt to pin center, exit before drawing control handles when holding alt, since alt-click will rotate scene view
108104
if (Event.current.alt)
@@ -126,11 +122,11 @@ public void DrawHandle()
126122

127123
// handles
128124
int prevHotControl = GUIUtility.hotControl;
129-
Handles.color = oldColor * handleColor;
130125
Vector3 cameraLocalPos = Handles.inverseMatrix.MultiplyPoint(Camera.current.transform.position);
131126
bool isCameraInsideBox = m_Bounds.Contains(cameraLocalPos);
132127
EditorGUI.BeginChangeCheck();
133-
MidpointHandles(ref minPos, ref maxPos, isCameraInsideBox);
128+
using (new Handles.DrawingScope(Handles.color * handleColor))
129+
MidpointHandles(ref minPos, ref maxPos, isCameraInsideBox);
134130
bool changed = EditorGUI.EndChangeCheck();
135131

136132
// detect if any handles got hotControl
@@ -178,9 +174,6 @@ public void DrawHandle()
178174
if (Event.current.alt)
179175
m_Bounds.center = m_BoundsOnClick.center;
180176
}
181-
182-
// Reset states
183-
Handles.color = oldColor;
184177
}
185178

186179
protected abstract void DrawWireframe();

Editor/Mono/EditorHandles/BoundsHandle/SphereBoundsHandle.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ protected override void DrawWireframe()
3838
Handles.DrawWireArc(center, Vector3.up, Vector3.right, 360f, radius);
3939
if (y && z)
4040
Handles.DrawWireArc(center, Vector3.right, Vector3.forward, 360f, radius);
41+
if (x && !y && !z)
42+
Handles.DrawLine(Vector3.right * radius, Vector3.left * radius);
43+
if (!x && y && !z)
44+
Handles.DrawLine(Vector3.up * radius, Vector3.down * radius);
45+
if (!x && !y && z)
46+
Handles.DrawLine(Vector3.forward * radius, Vector3.back * radius);
4147
}
4248

4349
protected override Bounds OnHandleChanged(HandleDirection handle, Bounds boundsOnClick, Bounds newBounds)

Editor/Mono/Inspector/DirectorEditor.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

55
using System;
6-
using System.IO;
76
using System.Linq;
8-
using System.Runtime.InteropServices;
97
using UnityEditorInternal;
10-
using System.Collections.Generic;
118
using UnityEngine;
129
using UnityEngine.Audio;
1310
using UnityEngine.Playables;
@@ -37,6 +34,7 @@ private static class Styles
3734
private SerializedProperty m_UpdateMethod;
3835

3936
private GUIContent m_AnimatorContent;
37+
private GUIContent m_AudioContent;
4038
private GUIContent m_ScriptContent;
4139
private Texture m_DefaultScriptContentTexture;
4240

@@ -49,6 +47,7 @@ public void OnEnable()
4947
m_InitialTime = serializedObject.FindProperty("m_InitialTime");
5048

5149
m_AnimatorContent = new GUIContent(AssetPreview.GetMiniTypeThumbnail(typeof(Animator)));
50+
m_AudioContent = new GUIContent(AssetPreview.GetMiniTypeThumbnail(typeof(AudioSource)));
5251
m_ScriptContent = new GUIContent(EditorGUIUtility.LoadIcon("ScriptableObject Icon"));
5352
m_DefaultScriptContentTexture = m_ScriptContent.image;
5453
}
@@ -84,7 +83,6 @@ public override void OnInspectorGUI()
8483
}
8584
}
8685

87-
8886
PropertyFieldAsFloat(m_InitialTime, Styles.InitialTimeContent);
8987

9088
if (Application.isPlaying)
@@ -112,6 +110,15 @@ private void BindingInspector(PlayableBinding binding, PlayableDirector director
112110

113111
if (binding.streamType == DataStreamType.Audio)
114112
{
113+
AudioSource source = director.GetGenericBinding(binding.sourceObject) as AudioSource;
114+
m_AudioContent.text = binding.streamName;
115+
m_AudioContent.tooltip = (source == null) ? Styles.NoBindingsContent.text : string.Empty;
116+
EditorGUI.BeginChangeCheck();
117+
source = EditorGUILayout.ObjectField(m_AudioContent, source, typeof(AudioSource), false) as AudioSource;
118+
if (EditorGUI.EndChangeCheck())
119+
{
120+
SetBinding(director, binding.sourceObject, source);
121+
}
115122
}
116123
else if (binding.streamType == DataStreamType.Animation)
117124
{
@@ -193,6 +200,8 @@ private static void PlayableAssetField(SerializedProperty property, GUIContent t
193200
if (EditorGUI.EndChangeCheck())
194201
{
195202
property.objectReferenceValue = prop;
203+
// some editors (like Timeline) needs to repaint when the playable asset changes
204+
InternalEditorUtility.RepaintAllViews();
196205
}
197206

198207
EditorGUI.EndProperty();

Editor/Mono/Inspector/Effector2DEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public override void OnInspectorGUI()
6868
public static void CheckEffectorWarnings(Collider2D collider)
6969
{
7070
// Finish if the collider is not used by the effector.
71-
if (!collider.usedByEffector)
71+
if (!collider.usedByEffector || collider.usedByComposite)
7272
return;
7373

7474
// Fetch the effector.

Editor/Mono/Inspector/LightProbeGroupInspector.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,11 @@ public void RemoveSelectedProbes()
182182

183183
public void PullProbePositions()
184184
{
185-
m_SourcePositions = new List<Vector3>(m_Group.probePositions);
186-
m_Selection = new List<int>(m_SerializedSelectedProbes.m_Selection);
185+
if (m_Group != null && m_SerializedSelectedProbes != null)
186+
{
187+
m_SourcePositions = new List<Vector3>(m_Group.probePositions);
188+
m_Selection = new List<int>(m_SerializedSelectedProbes.m_Selection);
189+
}
187190
}
188191

189192
public void PushProbePositions()

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ static class Styles
156156
public static readonly GUIContent apiCompatibilityLevel_NET_2_0 = EditorGUIUtility.TextContent(".NET 2.0");
157157
public static readonly GUIContent apiCompatibilityLevel_NET_2_0_Subset = EditorGUIUtility.TextContent(".NET 2.0 Subset");
158158
public static readonly GUIContent apiCompatibilityLevel_NET_4_6 = EditorGUIUtility.TextContent(".NET 4.6");
159+
public static readonly GUIContent activeInputHandling = EditorGUIUtility.TextContent("Active Input Handling*");
160+
public static readonly GUIContent[] activeInputHandlingOptions = new GUIContent[] { new GUIContent("Input Manager"), new GUIContent("Input System (Preview)"), new GUIContent("Both") };
159161

160162
public static string undoChangedBundleIdentifierString { get { return LocalizationDatabase.GetLocalizedString("Changed macOS bundleIdentifier"); } }
161163
public static string undoChangedBuildNumberString { get { return LocalizationDatabase.GetLocalizedString("Changed macOS build number"); } }
@@ -253,6 +255,8 @@ PlayerSettingsSplashScreenEditor splashScreenEditor
253255
SerializedProperty m_ActionOnDotNetUnhandledException;
254256
SerializedProperty m_LogObjCUncaughtExceptions;
255257
SerializedProperty m_EnableCrashReportAPI;
258+
SerializedProperty m_EnableInputSystem;
259+
SerializedProperty m_DisableInputManager;
256260

257261
// vita
258262
SerializedProperty m_VideoMemoryForVertexBuffers;
@@ -410,6 +414,8 @@ void OnEnable()
410414
m_ActionOnDotNetUnhandledException = FindPropertyAssert("actionOnDotNetUnhandledException");
411415
m_LogObjCUncaughtExceptions = FindPropertyAssert("logObjCUncaughtExceptions");
412416
m_EnableCrashReportAPI = FindPropertyAssert("enableCrashReportAPI");
417+
m_EnableInputSystem = FindPropertyAssert("enableNativePlatformBackendsForNewInputSystem");
418+
m_DisableInputManager = FindPropertyAssert("disableOldInputManagerSupport");
413419

414420
m_DefaultScreenWidth = FindPropertyAssert("defaultScreenWidth");
415421
m_DefaultScreenHeight = FindPropertyAssert("defaultScreenHeight");
@@ -1730,6 +1736,17 @@ private void OtherSectionConfigurationGUI(BuildTargetGroup targetGroup, ISetting
17301736
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, scriptDefines);
17311737
}
17321738

1739+
// Active input handling
1740+
int inputOption = (!m_EnableInputSystem.boolValue) ? 0 : m_DisableInputManager.boolValue ? 1 : 2;
1741+
EditorGUI.BeginChangeCheck();
1742+
inputOption = EditorGUILayout.Popup(Styles.activeInputHandling, inputOption, Styles.activeInputHandlingOptions);
1743+
if (EditorGUI.EndChangeCheck())
1744+
{
1745+
EditorUtility.DisplayDialog("Unity editor restart required", "The Unity editor must be restarted for this change to take effect.", "OK");
1746+
m_EnableInputSystem.boolValue = (inputOption == 1 || inputOption == 2);
1747+
m_DisableInputManager.boolValue = !(inputOption == 0 || inputOption == 2);
1748+
}
1749+
17331750
EditorGUILayout.Space();
17341751
}
17351752

0 commit comments

Comments
 (0)