Skip to content

Commit 6cd2e44

Browse files
author
Unity Technologies
committed
Unity 2017.1.2p4 C# reference source code
1 parent b5bc004 commit 6cd2e44

File tree

26 files changed

+123
-96
lines changed

26 files changed

+123
-96
lines changed

Editor/Mono/Animation/AnimationWindow/CurveEditor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3526,6 +3526,7 @@ void DrawWrapperPopups()
35263526

35273527
if (curve != null && curve.length >= 2 && curve.preWrapMode != WrapMode.Default)
35283528
{
3529+
GUI.BeginGroup(drawRect);
35293530
Color oldText = GUI.contentColor;
35303531

35313532
var preKey = curve.keys[0];
@@ -3554,6 +3555,7 @@ void DrawWrapperPopups()
35543555
}
35553556

35563557
GUI.contentColor = oldText;
3558+
GUI.EndGroup();
35573559
}
35583560
}
35593561

@@ -3562,7 +3564,7 @@ WrapMode WrapModeIconPopup(Keyframe key, WrapMode oldWrap, float hOffset)
35623564
float buttonSize = Styles.wrapModeMenuIcon.image.width;
35633565
var keyPosition = new Vector3(key.time, key.value);
35643566
keyPosition = DrawingToViewTransformPoint(keyPosition);
3565-
var r = new Rect(keyPosition.x + buttonSize * hOffset, keyPosition.y + drawRect.y, buttonSize, buttonSize);
3567+
var r = new Rect(keyPosition.x + buttonSize * hOffset, keyPosition.y, buttonSize, buttonSize);
35663568

35673569
var selectedValue = (WrapModeFixedCurve)oldWrap;
35683570

Editor/Mono/AssemblyHelper.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ static public void CheckForAssemblyFileNameMismatch(string assemblyPath)
2222
{
2323
string fileName = Path.GetFileNameWithoutExtension(assemblyPath);
2424
string assemblyName = ExtractInternalAssemblyName(assemblyPath);
25+
26+
if (string.IsNullOrEmpty(assemblyName))
27+
return;
28+
2529
if (fileName != assemblyName)
2630
{
2731
Debug.LogWarning("Assembly '" + assemblyName + "' has non matching file name: '" + Path.GetFileName(assemblyPath) + "'. This can cause build issues on some platforms.");
@@ -66,8 +70,15 @@ public static Assembly FindLoadedAssemblyWithName(string s)
6670

6771
static public string ExtractInternalAssemblyName(string path)
6872
{
69-
AssemblyDefinition definition = AssemblyDefinition.ReadAssembly(path);
70-
return definition.Name.Name;
73+
try
74+
{
75+
AssemblyDefinition definition = AssemblyDefinition.ReadAssembly(path);
76+
return definition.Name.Name;
77+
}
78+
catch
79+
{
80+
return ""; // Possible on just deleted FacebookSDK
81+
}
7182
}
7283

7384
static AssemblyDefinition GetAssemblyDefinitionCached(string path, Dictionary<string, AssemblyDefinition> cache)

Editor/Mono/Inspector/LightEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void LightUsageGUI()
182182
// Baking type
183183
if (EditorGUILayout.BeginFadeGroup(1.0F - m_AnimShowAreaOptions.faded))
184184
{
185-
LightModeUtil.Get().DrawElement(m_Lightmapping, s_Styles.LightmappingMode);
185+
EditorGUILayout.PropertyField(m_Lightmapping, s_Styles.LightmappingMode);
186186

187187
// Warning if GI Baking disabled and m_Lightmapping isn't realtime
188188
if (bakingWarningValue)

Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsEditor.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,13 +1745,17 @@ private void OtherSectionConfigurationGUI(BuildTargetGroup targetGroup, ISetting
17451745

17461746
// Active input handling
17471747
int inputOption = (!m_EnableInputSystem.boolValue) ? 0 : m_DisableInputManager.boolValue ? 1 : 2;
1748+
int oldInputOption = inputOption;
17481749
EditorGUI.BeginChangeCheck();
17491750
inputOption = EditorGUILayout.Popup(Styles.activeInputHandling, inputOption, Styles.activeInputHandlingOptions);
17501751
if (EditorGUI.EndChangeCheck())
17511752
{
1752-
EditorUtility.DisplayDialog("Unity editor restart required", "The Unity editor must be restarted for this change to take effect.", "OK");
1753-
m_EnableInputSystem.boolValue = (inputOption == 1 || inputOption == 2);
1754-
m_DisableInputManager.boolValue = !(inputOption == 0 || inputOption == 2);
1753+
if (inputOption != oldInputOption)
1754+
{
1755+
EditorUtility.DisplayDialog("Unity editor restart required", "The Unity editor must be restarted for this change to take effect.", "OK");
1756+
m_EnableInputSystem.boolValue = (inputOption == 1 || inputOption == 2);
1757+
m_DisableInputManager.boolValue = !(inputOption == 0 || inputOption == 2);
1758+
}
17551759
}
17561760

17571761
EditorGUILayout.Space();

Editor/Mono/Inspector/ReflectionProbeEditor.cs

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,36 @@ internal class ReflectionProbeEditor : Editor
5353

5454
private Hashtable m_CachedGizmoMaterials = new Hashtable();
5555

56-
static internal class Styles
56+
public static void GetResolutionArray(ref int[] resolutionList, ref GUIContent[] resolutionStringList)
5757
{
58-
static Styles()
58+
if (Styles.reflectionResolutionValuesArray == null && Styles.reflectionResolutionTextArray == null)
5959
{
60-
richTextMiniLabel.richText = true;
61-
62-
// Create a list of cubemap resolutions
63-
renderTextureSizesValues.Clear();
64-
renderTextureSizes.Clear();
60+
int cubemapResolution = Mathf.Max(1, ReflectionProbe.minBakedCubemapResolution);
6561

66-
int cubemapResolution = ReflectionProbe.minBakedCubemapResolution;
62+
List<int> envReflectionResolutionValues = new List<int>();
63+
List<GUIContent> envReflectionResolutionText = new List<GUIContent>();
6764

6865
do
6966
{
70-
renderTextureSizesValues.Add(cubemapResolution);
71-
renderTextureSizes.Add(new GUIContent(cubemapResolution.ToString()));
67+
envReflectionResolutionValues.Add(cubemapResolution);
68+
envReflectionResolutionText.Add(new GUIContent(cubemapResolution.ToString()));
7269
cubemapResolution *= 2;
7370
}
7471
while (cubemapResolution <= ReflectionProbe.maxBakedCubemapResolution);
72+
73+
Styles.reflectionResolutionValuesArray = envReflectionResolutionValues.ToArray();
74+
Styles.reflectionResolutionTextArray = envReflectionResolutionText.ToArray();
75+
}
76+
77+
resolutionList = Styles.reflectionResolutionValuesArray;
78+
resolutionStringList = Styles.reflectionResolutionTextArray;
79+
}
80+
81+
static internal class Styles
82+
{
83+
static Styles()
84+
{
85+
richTextMiniLabel.richText = true;
7586
}
7687

7788
public static GUIStyle richTextMiniLabel = new GUIStyle(EditorStyles.miniLabel);
@@ -101,8 +112,8 @@ static Styles()
101112
public static GUIContent[] reflectionProbeMode = { new GUIContent("Baked"), new GUIContent("Custom"), new GUIContent("Realtime") };
102113
public static int[] reflectionProbeModeValues = { (int)ReflectionProbeMode.Baked, (int)ReflectionProbeMode.Custom, (int)ReflectionProbeMode.Realtime };
103114

104-
public static List<int> renderTextureSizesValues = new List<int>();
105-
public static List<GUIContent> renderTextureSizes = new List<GUIContent>();
115+
public static int[] reflectionResolutionValuesArray = null;
116+
public static GUIContent[] reflectionResolutionTextArray = null;
106117

107118
public static GUIContent[] clearFlags =
108119
{
@@ -481,7 +492,11 @@ public override void OnInspectorGUI()
481492

482493
EditorGUI.indentLevel++;
483494
{
484-
EditorGUILayout.IntPopup(m_Resolution, Styles.renderTextureSizes.ToArray(), Styles.renderTextureSizesValues.ToArray(), Styles.resolutionText, GUILayout.MinWidth(40));
495+
int[] reflectionResolutionValuesArray = null;
496+
GUIContent[] reflectionResolutionTextArray = null;
497+
GetResolutionArray(ref reflectionResolutionValuesArray, ref reflectionResolutionTextArray);
498+
499+
EditorGUILayout.IntPopup(m_Resolution, reflectionResolutionTextArray, reflectionResolutionValuesArray, Styles.resolutionText, GUILayout.MinWidth(40));
485500
EditorGUILayout.PropertyField(m_HDR);
486501
EditorGUILayout.PropertyField(m_ShadowDistance);
487502
EditorGUILayout.IntPopup(m_ClearFlags, Styles.clearFlags, Styles.clearFlagsValues, Styles.clearFlagsText);
@@ -562,13 +577,14 @@ public override void OnPreviewSettings()
562577

563578
public override void OnPreviewGUI(Rect position, GUIStyle style)
564579
{
565-
if (!ValidPreviewSetup())
580+
// Fix for case 939947 where we didn't get the Layout event if the texture was null when changing color
581+
if (!ValidPreviewSetup() && Event.current.type != EventType.ExecuteCommand)
566582
{
567583
GUILayout.BeginHorizontal();
568584
GUILayout.FlexibleSpace();
569585
Color prevColor = GUI.color;
570586
GUI.color = new Color(1, 1, 1, 0.5f);
571-
GUILayout.Label("Reflection Probe not baked yet");
587+
GUILayout.Label("Reflection Probe not baked/ready yet");
572588
GUI.color = prevColor;
573589
GUILayout.FlexibleSpace();
574590
GUILayout.EndHorizontal();

Editor/Mono/Modules/DefaultPluginImporterExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public virtual string CalculateFinalPluginPath(string platformName, PluginImport
144144

145145
protected Dictionary<string, List<PluginImporter>> GetCompatiblePlugins(string buildTargetName)
146146
{
147-
PluginImporter[] plugins = PluginImporter.GetAllImporters().Where(imp => (imp.GetCompatibleWithPlatform(buildTargetName) || imp.GetCompatibleWithAnyPlatform()) && !string.IsNullOrEmpty(imp.assetPath)).ToArray();
147+
IEnumerable<PluginImporter> plugins = PluginImporter.GetAllImporters().Where(imp => imp.GetCompatibleWithPlatformOrAnyPlatformBuildTarget(buildTargetName));
148148
Dictionary<string, List<PluginImporter>> matchingPlugins = new Dictionary<string, List<PluginImporter>>();
149149

150150
foreach (var plugin in plugins)

Editor/Mono/PluginImporter.bindings.cs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,11 @@ namespace UnityEditor
1919
[NativeHeader("Editor/Src/AssetPipeline/PluginImporter.h")]
2020
public sealed partial class PluginImporter : AssetImporter
2121
{
22-
private static bool IsCompatible(PluginImporter imp, string platformName)
23-
{
24-
if (string.IsNullOrEmpty(imp.assetPath))
25-
return false;
22+
[NativeMethod("GetCompatibleWithPlatformOrAnyPlatform")]
23+
extern internal bool GetCompatibleWithPlatformOrAnyPlatformBuildTarget(string buildTarget);
2624

27-
if (!imp.GetCompatibleWithPlatform(platformName) &&
28-
!(imp.GetCompatibleWithAnyPlatform() && !imp.GetExcludeFromAnyPlatform(platformName)))
29-
{
30-
return false;
31-
}
32-
33-
return imp.ShouldIncludeInBuild();
34-
}
35-
36-
private static bool IsCompatible(PluginImporter imp, string buildTargetGroup, string buildTarget)
37-
{
38-
if (string.IsNullOrEmpty(imp.assetPath))
39-
return false;
40-
41-
return imp.GetCompatibleWithPlatform(buildTargetGroup, buildTarget) || imp.GetCompatibleWithAnyPlatform();
42-
}
25+
[NativeMethod("GetCompatibleWithPlatformOrAnyPlatform")]
26+
extern private bool GetCompatibleWithPlatformOrAnyPlatformBuildGroupAndTarget(string buildTargetGroup, string buildTarget);
4327

4428
public static PluginImporter[] GetImporters(string platformName)
4529
{
@@ -49,7 +33,7 @@ public static PluginImporter[] GetImporters(string platformName)
4933
// Contains all unique finalPaths. Used to remove overridable plugins from the finalImporters list
5034
Dictionary<string, PluginImporter> uniqueFinalPathToImporterMap = new Dictionary<string, PluginImporter>();
5135

52-
PluginImporter[] allImporters = GetAllImporters().Where(imp => IsCompatible(imp, platformName)).ToArray();
36+
PluginImporter[] allImporters = GetAllImporters().Where(imp => imp.GetCompatibleWithPlatformOrAnyPlatformBuildTarget(platformName)).ToArray();
5337
IPluginImporterExtension pluginImporterExtension = ModuleManager.GetPluginImporterExtension(platformName);
5438

5539
if (pluginImporterExtension == null)
@@ -103,7 +87,7 @@ public static PluginImporter[] GetImporters(BuildTarget platform)
10387

10488
public static PluginImporter[] GetImporters(string buildTargetGroup, string buildTarget)
10589
{
106-
return GetAllImporters().Where(imp => IsCompatible(imp, buildTargetGroup, buildTarget)).ToArray();
90+
return GetAllImporters().Where(imp => imp.GetCompatibleWithPlatformOrAnyPlatformBuildGroupAndTarget(buildTargetGroup, buildTarget)).ToArray();
10791
}
10892

10993
public static PluginImporter[] GetImporters(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget)

Editor/Mono/SceneModeWindows/LightModeUtil.cs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ internal enum LightmapMixedBakeMode
2222
}
2323

2424
public static readonly GUIContent s_enableBaked = EditorGUIUtility.TextContent("Baked Global Illumination|Controls whether Mixed and Baked lights will use baked Global Illumination. If enabled, Mixed lights are baked using the specified Lighting Mode and Baked lights will be completely baked and not adjustable at runtime.");
25-
public static readonly string[] s_typenames = { "Realtime", "Mixed", "Baked" };
26-
private static readonly GUIContent[] s_modes =
27-
{
28-
new GUIContent(s_typenames[0]),
29-
new GUIContent(s_typenames[1]),
30-
new GUIContent(s_typenames[2])
31-
};
25+
3226
// combobox content
3327
private int[] m_modeVals = { 0, 0, 0 };
3428
// cached data
@@ -161,32 +155,6 @@ public bool Flush()
161155
return m_so.ApplyModifiedProperties();
162156
}
163157

164-
// helper function to draw the context sensitive combobox in the lighting explorer
165-
public void DrawElement(Rect r, SerializedProperty property, SerializedProperty dependency)
166-
{
167-
bool is_area = dependency.enumValueIndex == (int)LightType.Area;
168-
using (new EditorGUI.DisabledScope(is_area))
169-
{
170-
EditorGUI.BeginChangeCheck();
171-
int newval = EditorGUI.IntPopup(r, property.intValue, s_modes, new int[] { 4, 1, 2 });
172-
if (EditorGUI.EndChangeCheck())
173-
{
174-
property.intValue = newval;
175-
}
176-
}
177-
}
178-
179-
// helper function to draw the context sensitive combobox in the light inspector
180-
public void DrawElement(SerializedProperty property, GUIContent label)
181-
{
182-
EditorGUI.BeginChangeCheck();
183-
int newval = EditorGUILayout.IntPopup(label, property.intValue, s_modes, new int[] { 4, 1, 2 });
184-
if (EditorGUI.EndChangeCheck())
185-
{
186-
property.intValue = newval;
187-
}
188-
}
189-
190158
// helper function to draw the checkbox for enabling baked GI
191159
public void DrawBakedGIElement()
192160
{

Editor/Mono/SceneModeWindows/LightTable.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ public static SerializedPropertyTreeView.Column[] CreateLightColumns(out string[
113113
propertyName = "m_Lightmapping",
114114
dependencyIndices = new int[] { 2 },
115115
compareDelegate = SerializedPropertyTreeView.DefaultDelegates.s_CompareEnum,
116-
drawDelegate = (Rect r, SerializedProperty prop, SerializedProperty[] dep) =>
117-
{
118-
LightModeUtil.Get().DrawElement(r, prop, dep[0]);
119-
}
116+
drawDelegate = SerializedPropertyTreeView.DefaultDelegates.s_DrawDefault
120117
},
121118
new SerializedPropertyTreeView.Column // 4: Color
122119
{

Editor/Mono/SceneView/SceneView.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ override public void OnEnable()
436436
public SceneView()
437437
{
438438
m_HierarchyType = HierarchyType.GameObjects;
439-
// Note: we always render into a custom RT, so no need for depth buffer or AA on the window itself
439+
440+
// Note: Rendering for Scene view picking depends on the depth buffer of the window
441+
depthBufferBits = 32;
440442
}
441443

442444
internal void Awake()

0 commit comments

Comments
 (0)