Skip to content

Commit 1ff7751

Browse files
author
Unity Technologies
committed
Unity 2018.1.0b3 C# reference source code
1 parent 8666305 commit 1ff7751

File tree

28 files changed

+473
-90
lines changed

28 files changed

+473
-90
lines changed

Editor/Mono/Collab/Collab.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace UnityEditor.Collaboration
1818
{
1919
internal delegate void StateChangedDelegate(CollabInfo info);
20+
internal delegate void ErrorDelegate();
2021

2122
[Flags]
2223
internal enum CollabOperation : ulong
@@ -51,6 +52,8 @@ internal partial class Collab
5152
public event StateChangedDelegate StateChanged;
5253
public event StateChangedDelegate RevisionUpdated;
5354
public event StateChangedDelegate JobsCompleted;
55+
public event ErrorDelegate ErrorOccurred;
56+
public event ErrorDelegate ErrorCleared;
5457

5558
private static Collab s_Instance;
5659
private static bool s_IsFirstStateChange = true;
@@ -269,6 +272,7 @@ private static void OnStateChanged()
269272
}
270273
}
271274

275+
[RequiredByNativeCode]
272276
private static void OnRevisionUpdated()
273277
{
274278
var handler = instance.RevisionUpdated;
@@ -278,6 +282,22 @@ private static void OnRevisionUpdated()
278282
}
279283
}
280284

285+
[RequiredByNativeCode]
286+
private static void SetCollabError()
287+
{
288+
var handler = instance.ErrorOccurred;
289+
if (handler != null)
290+
handler();
291+
}
292+
293+
[RequiredByNativeCode]
294+
private static void ClearCollabError()
295+
{
296+
var handler = instance.ErrorCleared;
297+
if (handler != null)
298+
handler();
299+
}
300+
281301
private static void OnJobsCompleted()
282302
{
283303
var handler = instance.JobsCompleted;

Editor/Mono/Collab/CollabHistoryWindow.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public static bool ValidateShowHistoryWindow()
3939
VisualElement m_Container;
4040
PagedListView m_Pager;
4141
int m_ItemsPerPage = 5;
42-
string m_ErrMessage;
4342
string m_InProgressRev;
4443
bool m_RevisionActionsEnabled;
4544

@@ -244,12 +243,6 @@ public int itemsPerPage
244243
}
245244
}
246245

247-
public string errMessage
248-
{
249-
private get { return m_ErrMessage; }
250-
set { m_ErrMessage = value; }
251-
}
252-
253246
public PageChangeAction OnPageChangeAction
254247
{
255248
set { m_Pager.OnPageChange = value; }

Editor/Mono/Collab/Presenters/CollabHistoryPresenter.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ internal class CollabHistoryPresenter
1515
IRevisionsService m_Service;
1616
ConnectInfo m_ConnectState;
1717
CollabInfo m_CollabState;
18+
bool m_IsCollabError;
1819
int m_TotalRevisions;
1920
int m_CurrentPage;
2021
BuildAccess m_BuildAccess;
@@ -36,6 +37,8 @@ public void OnWindowEnabled()
3637
Collab.instance.StateChanged += OnCollabStateChanged;
3738
Collab.instance.RevisionUpdated += OnCollabRevisionUpdated;
3839
Collab.instance.JobsCompleted += OnCollabJobsCompleted;
40+
Collab.instance.ErrorOccurred += OnCollabError;
41+
Collab.instance.ErrorCleared += OnCollabErrorCleared;
3942
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
4043

4144
if (Collab.instance.IsConnected())
@@ -133,6 +136,18 @@ private void OnCollabJobsCompleted(CollabInfo state)
133136
m_ProgressRevision = null;
134137
}
135138

139+
private void OnCollabError()
140+
{
141+
m_IsCollabError = true;
142+
m_Window.UpdateState(RecalculateState(), false);
143+
}
144+
145+
private void OnCollabErrorCleared()
146+
{
147+
m_IsCollabError = false;
148+
m_Window.UpdateState(RecalculateState(), false);
149+
}
150+
136151
private void OnPlayModeStateChanged(PlayModeStateChange stateChange)
137152
{
138153
// If entering play mode, disable
@@ -151,11 +166,6 @@ private void OnPlayModeStateChanged(PlayModeStateChange stateChange)
151166

152167
private HistoryState RecalculateState()
153168
{
154-
if (m_ConnectState.error)
155-
{
156-
m_Window.errMessage = m_ConnectState.lastErrorMsg;
157-
return HistoryState.Error;
158-
}
159169
if (!m_ConnectState.online)
160170
return HistoryState.Offline;
161171
if (m_ConnectState.maintenance || m_CollabState.maintenance)
@@ -168,6 +178,8 @@ private HistoryState RecalculateState()
168178
return HistoryState.Disabled;
169179
if (!Collab.instance.IsConnected() || !m_CollabState.ready)
170180
return HistoryState.Waiting;
181+
if (m_ConnectState.error || m_IsCollabError)
182+
return HistoryState.Error;
171183

172184
return HistoryState.Ready;
173185
}

Editor/Mono/Collab/Views/ICollabHistoryWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ internal interface ICollabHistoryWindow
6969

7070
bool revisionActionsEnabled { get; set; }
7171
int itemsPerPage { set; }
72-
string errMessage { set; }
7372
string inProgressRevision { get; set; }
7473
PageChangeAction OnPageChangeAction { set; }
7574
RevisionAction OnGoBackAction { set; }

Editor/Mono/ContainerWindow.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ internal bool IsNotDocked()
187187

188188
(m_ShowMode == (int)ShowMode.Utility || m_ShowMode == (int)ShowMode.AuxWindow) ||
189189

190-
(rootView as SplitView != null &&
191-
rootView.children.Length == 1 &&
190+
(rootView is SplitView &&
192191
rootView.children.Length == 1 &&
193192
rootView.children[0] is DockArea &&
194193
((DockArea)rootView.children[0]).m_Panes.Count == 1)

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static class Styles
4646
public static readonly GUIContent recordingInfo = EditorGUIUtility.TrTextContent("Reordering the list will switch editor to the first available platform");
4747
public static readonly GUIContent notApplicableInfo = EditorGUIUtility.TrTextContent("Not applicable for this platform.");
4848
public static readonly GUIContent sharedBetweenPlatformsInfo = EditorGUIUtility.TrTextContent("* Shared setting between multiple platforms.");
49-
public static readonly GUIContent VRSupportOverridenInfo = EditorGUIUtility.TrTextContent("This setting is overridden by Virtual Reality Support.");
49+
public static readonly GUIContent vrOrientationInfo = EditorGUIUtility.TrTextContent("Virtual Reality Support is enabled. Upon entering VR mode, landscape left orientation will be the default orientation unless only landscape right is available.");
5050
public static readonly GUIContent IL2CPPAndroidExperimentalInfo = EditorGUIUtility.TrTextContent("IL2CPP on Android is experimental and unsupported");
5151

5252
public static readonly GUIContent cursorHotspot = EditorGUIUtility.TrTextContent("Cursor Hotspot");
@@ -847,42 +847,39 @@ public void ResolutionSectionGUI(BuildTargetGroup targetGroup, ISettingEditorExt
847847
{
848848
GUILayout.Label(Styles.orientationTitle, EditorStyles.boldLabel);
849849

850-
using (new EditorGUI.DisabledScope(PlayerSettings.virtualRealitySupported))
851-
{
852-
EditorGUILayout.PropertyField(m_DefaultScreenOrientation, Styles.defaultScreenOrientation);
850+
EditorGUILayout.PropertyField(m_DefaultScreenOrientation, Styles.defaultScreenOrientation);
853851

854-
if (PlayerSettings.virtualRealitySupported)
855-
{
856-
EditorGUILayout.HelpBox(Styles.VRSupportOverridenInfo.text, MessageType.Info);
857-
}
852+
if (PlayerSettings.virtualRealitySupported)
853+
{
854+
EditorGUILayout.HelpBox(Styles.vrOrientationInfo.text, MessageType.Warning);
855+
}
858856

859-
if (m_DefaultScreenOrientation.enumValueIndex == 4)
860-
{
861-
if (targetGroup == BuildTargetGroup.iOS || targetGroup == BuildTargetGroup.Tizen)
862-
EditorGUILayout.PropertyField(m_UseOSAutoRotation, Styles.useOSAutoRotation);
857+
if (m_DefaultScreenOrientation.enumValueIndex == (int)UIOrientation.AutoRotation)
858+
{
859+
if (targetGroup == BuildTargetGroup.iOS || targetGroup == BuildTargetGroup.Tizen)
860+
EditorGUILayout.PropertyField(m_UseOSAutoRotation, Styles.useOSAutoRotation);
863861

864-
EditorGUI.indentLevel++;
862+
EditorGUI.indentLevel++;
865863

866-
GUILayout.Label(Styles.allowedOrientationTitle, EditorStyles.boldLabel);
864+
GUILayout.Label(Styles.allowedOrientationTitle, EditorStyles.boldLabel);
867865

868-
bool somethingAllowed = m_AllowedAutoRotateToPortrait.boolValue
869-
|| m_AllowedAutoRotateToPortraitUpsideDown.boolValue
870-
|| m_AllowedAutoRotateToLandscapeRight.boolValue
871-
|| m_AllowedAutoRotateToLandscapeLeft.boolValue;
866+
bool somethingAllowed = m_AllowedAutoRotateToPortrait.boolValue
867+
|| m_AllowedAutoRotateToPortraitUpsideDown.boolValue
868+
|| m_AllowedAutoRotateToLandscapeRight.boolValue
869+
|| m_AllowedAutoRotateToLandscapeLeft.boolValue;
872870

873-
if (!somethingAllowed)
874-
{
875-
m_AllowedAutoRotateToPortrait.boolValue = true;
876-
Debug.LogError("All orientations are disabled. Allowing portrait");
877-
}
871+
if (!somethingAllowed)
872+
{
873+
m_AllowedAutoRotateToPortrait.boolValue = true;
874+
Debug.LogError("All orientations are disabled. Allowing portrait");
875+
}
878876

879-
EditorGUILayout.PropertyField(m_AllowedAutoRotateToPortrait, Styles.allowedAutoRotateToPortrait);
880-
EditorGUILayout.PropertyField(m_AllowedAutoRotateToPortraitUpsideDown, Styles.allowedAutoRotateToPortraitUpsideDown);
881-
EditorGUILayout.PropertyField(m_AllowedAutoRotateToLandscapeRight, Styles.allowedAutoRotateToLandscapeRight);
882-
EditorGUILayout.PropertyField(m_AllowedAutoRotateToLandscapeLeft, Styles.allowedAutoRotateToLandscapeLeft);
877+
EditorGUILayout.PropertyField(m_AllowedAutoRotateToPortrait, Styles.allowedAutoRotateToPortrait);
878+
EditorGUILayout.PropertyField(m_AllowedAutoRotateToPortraitUpsideDown, Styles.allowedAutoRotateToPortraitUpsideDown);
879+
EditorGUILayout.PropertyField(m_AllowedAutoRotateToLandscapeRight, Styles.allowedAutoRotateToLandscapeRight);
880+
EditorGUILayout.PropertyField(m_AllowedAutoRotateToLandscapeLeft, Styles.allowedAutoRotateToLandscapeLeft);
883881

884-
EditorGUI.indentLevel--;
885-
}
882+
EditorGUI.indentLevel--;
886883
}
887884
}
888885

Editor/Mono/ParticleSystemEditor/ParticleSystemModules/InitialModuleUI.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ override public void UpdateCullingSupportedString(ref string text)
304304

305305
if (m_GravityModifier.state != MinMaxCurveState.k_Scalar)
306306
text += "\nGravity modifier is not constant.";
307+
308+
if (m_StopAction.intValue != 0)
309+
text += "\nStop Action is being used.";
307310
}
308311
}
309312
} // namespace UnityEditor

Editor/Mono/ParticleSystemEditor/ParticleSystemUI.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ internal class ParticleSystemUI
2121
private string m_SupportsCullingText;
2222
private string m_SupportsCullingTextLabel; // Cached version including bullet points
2323

24-
// Keep in sync with ParticleSystemEditor.h
25-
public enum DefaultTypes
26-
{
27-
Root,
28-
SubBirth,
29-
SubCollision,
30-
SubDeath,
31-
};
32-
3324
protected class Texts
3425
{
3526
public GUIContent addModules = new GUIContent("", "Show/Hide Modules");
@@ -64,7 +55,7 @@ public void Init(ParticleEffectUI owner, ParticleSystem[] systems)
6455

6556
internal ModuleUI GetParticleSystemRendererModuleUI()
6657
{
67-
return m_Modules[m_Modules.Length - 1];
58+
return m_Modules.Last();
6859
}
6960

7061
private void InitRendererUI()
@@ -84,10 +75,10 @@ private void InitRendererUI()
8475
// Create RendererModuleUI
8576
if (renderers.Count > 0)
8677
{
87-
System.Diagnostics.Debug.Assert(m_Modules[m_Modules.Length - 1] == null); // If hitting this assert we have either not cleaned up the previous renderer or hitting another module
78+
System.Diagnostics.Debug.Assert(m_Modules.Last() == null); // If hitting this assert we have either not cleaned up the previous renderer or hitting another module
8879

8980
m_RendererSerializedObject = new SerializedObject(renderers.ToArray());
90-
m_Modules[m_Modules.Length - 1] = new RendererModuleUI(this, m_RendererSerializedObject, s_ModuleNames[s_ModuleNames.Length - 1]);
81+
m_Modules[m_Modules.Length - 1] = new RendererModuleUI(this, m_RendererSerializedObject, s_ModuleNames.Last());
9182
}
9283
}
9384

@@ -465,7 +456,7 @@ void ResetModules()
465456
}
466457

467458
// Default setup has a renderer
468-
if (m_Modules[m_Modules.Length - 1] == null)
459+
if (m_Modules.Last() == null)
469460
InitRendererUI();
470461

471462
// Default setup has shape, emission and renderer

Editor/Mono/PlatformSupport/PlayerSettingsPlatformIcons.bindings.cs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,17 @@ public static PlatformIcon[] GetPlatformIcons(BuildTargetGroup platform, Platfor
252252
PlatformIconStruct[] serializedIcons = GetPlatformIconsInternal(platformName, kind.kind);
253253
PlatformIcon[] icons = PlatformIcon.GetRequiredPlatformIconsByType(platformIconProvider, kind);
254254

255+
if (serializedIcons.Length <= 0)
256+
{
257+
ImportLegacyIcons(platform, kind, icons);
258+
SetPlatformIcons(platform, kind, icons);
259+
}
260+
255261
if (serializedIcons.Length <= 0)
256262
{
257263
foreach (var icon in icons)
258-
icon.SetTextures(null);
264+
if (icon.IsEmpty())
265+
icon.SetTextures(null);
259266
}
260267
else
261268
{
@@ -332,6 +339,13 @@ internal static int GetNonEmptyPlatformIconCount(PlatformIcon[] icons)
332339
return icons.Count(i => !i.IsEmpty());
333340
}
334341

342+
internal static int GetValidPlatformIconCount(PlatformIcon[] icons)
343+
{
344+
return icons.Count(
345+
i => i.GetTextures().Count(t => t != null) >= i.minLayerCount && i.layerCount <= i.maxLayerCount
346+
);
347+
}
348+
335349
[StaticAccessor("GetPlayerSettings()", StaticAccessorType.Dot)]
336350
[NativeMethod(Name = "SetIconsForPlatform")]
337351
extern internal static void SetPlatformIconsInternal(string platform, PlatformIconStruct[] icons, int kind);
@@ -351,8 +365,6 @@ internal static void ClearSetIconsForPlatform(BuildTargetGroup target)
351365

352366
// Old API methods, will be made obsolete when the new API is implemented for all platforms,
353367
// currently it functions as a wrapper for the new API for all platforms that support it (iOS, Android & tvOS).
354-
355-
356368
public static void SetIconsForTargetGroup(BuildTargetGroup platform, Texture2D[] icons, IconKind kind)
357369
{
358370
if (platform == BuildTargetGroup.iOS || platform == BuildTargetGroup.tvOS || platform == BuildTargetGroup.Android)
@@ -402,6 +414,37 @@ public static Texture2D[] GetIconsForTargetGroup(BuildTargetGroup platform, Icon
402414
}
403415
}
404416

417+
internal static void ImportLegacyIcons(string platform, PlatformIconKind kind, PlatformIcon[] platformIcons)
418+
{
419+
if (!Enum.IsDefined(typeof(IconKind), kind.kind))
420+
return;
421+
422+
IconKind iconKind = (IconKind)kind.kind;
423+
424+
Texture2D[] legacyIcons = GetIconsForPlatform(platform, iconKind);
425+
int[] legacyIconWidths = GetIconWidthsForPlatform(platform, iconKind);
426+
int[] legacyIconHeights = GetIconHeightsForPlatform(platform, iconKind);
427+
428+
for (var i = 0; i < legacyIcons.Length; i++)
429+
{
430+
List<PlatformIcon> selectedIcons = new List<PlatformIcon>();
431+
foreach (var icon in platformIcons)
432+
{
433+
if (icon.width == legacyIconWidths[i] && icon.height == legacyIconHeights[i])
434+
{
435+
selectedIcons.Add(icon);
436+
}
437+
}
438+
foreach (var selectedIcon in selectedIcons)
439+
selectedIcon.SetTextures(legacyIcons[i]);
440+
}
441+
}
442+
443+
internal static void ImportLegacyIcons(BuildTargetGroup platform, PlatformIconKind kind, PlatformIcon[] platformIcons)
444+
{
445+
ImportLegacyIcons(GetPlatformName(platform), kind, platformIcons);
446+
}
447+
405448
// Returns the list of assigned icons for the specified platform.
406449
public static Texture2D[] GetIconsForTargetGroup(BuildTargetGroup platform)
407450
{

0 commit comments

Comments
 (0)