Skip to content

Commit 517a93f

Browse files
author
Unity Technologies
committed
Unity 2017.2.0p2 C# reference source code
1 parent 63de852 commit 517a93f

39 files changed

+192
-121
lines changed

Editor/Mono/2D/Common/TexturePlatformSettingsFormatHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public void AcquireTextureFormatValuesAndStrings(BuildTarget buildTarget, out in
4141
formatValues = TextureImportPlatformSettings.kTextureFormatsValueWiiU;
4242
formatStrings = TextureImporterInspector.s_TextureFormatStringsWiiU;
4343
}
44+
else if (buildTarget == BuildTarget.PSP2)
45+
{
46+
formatValues = TextureImportPlatformSettings.kTextureFormatsValuePSP2;
47+
formatStrings = TextureImporterInspector.s_TextureFormatStringsPSP2;
48+
}
4449
else
4550
{
4651
formatValues = TextureImportPlatformSettings.kTextureFormatsValueDefault;

Editor/Mono/2D/SpriteAtlas/SpriteAtlasInspector.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class Styles
6464
public readonly GUIContent disabledPackLabel = EditorGUIUtility.TextContent("Sprite Atlas packing is disabled. Enable it in Edit > Project Settings > Editor.");
6565
public readonly GUIContent packableListLabel = EditorGUIUtility.TextContent("Objects for Packing|Only accept Folder, Sprite Sheet(Texture) and Sprite.");
6666

67+
public readonly GUIContent notPowerOfTwoWarning = EditorGUIUtility.TextContent("This scale will produce a Sprite Atlas variant with a packed texture that is NPOT (non - power of two). This may cause visual artifacts in certain compression/texture formats.");
68+
6769
public readonly GUIContent smallZoom = EditorGUIUtility.IconContent("PreTextureMipMapLow");
6870
public readonly GUIContent largeZoom = EditorGUIUtility.IconContent("PreTextureMipMapHigh");
6971
public readonly GUIContent alphaIcon = EditorGUIUtility.IconContent("PreTextureAlpha");
@@ -383,6 +385,10 @@ private void HandleVariantSettingUI()
383385
{
384386
EditorGUILayout.LabelField(s_Styles.variantSettingLabel, EditorStyles.boldLabel);
385387
EditorGUILayout.PropertyField(m_VariantMultiplier, s_Styles.variantMultiplierLabel);
388+
389+
// Test if the multiplier scale a power of two size (1024) into another power of 2 size.
390+
if (!Mathf.IsPowerOfTwo((int)(m_VariantMultiplier.floatValue * 1024)))
391+
EditorGUILayout.HelpBox(s_Styles.notPowerOfTwoWarning.text, MessageType.Warning, true);
386392
}
387393

388394
private void HandleBoolToIntPropertyField(SerializedProperty prop, GUIContent content)

Editor/Mono/AssetPipeline/ModelImporter.bindings.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ public Avatar sourceAvatar
729729
{
730730
get
731731
{
732-
return sourceAvatarInternal;
732+
return GetSourceAvatar();
733733
}
734734
set
735735
{
@@ -749,18 +749,13 @@ public Avatar sourceAvatar
749749
}
750750
}
751751

752-
sourceAvatarInternal = avatar;
752+
SetSourceAvatarInternal(this, avatar);
753753
}
754754
}
755-
internal Avatar sourceAvatarInternal
756-
{
757-
get { return GetSourceAvatarInternal(this); }
758-
set { SetSourceAvatarInternal(this, value); }
759-
}
760-
[FreeFunction("ModelImporterBindings::GetSourceAvatarInternal")]
761-
private extern static Avatar GetSourceAvatarInternal(ModelImporter self);
755+
756+
private extern Avatar GetSourceAvatar();
762757
[FreeFunction("ModelImporterBindings::SetSourceAvatarInternal")]
763-
private extern static void SetSourceAvatarInternal([Writable] ModelImporter self, Avatar value);
758+
private extern static void SetSourceAvatarInternal(ModelImporter self, Avatar value);
764759

765760
[System.Obsolete("splitAnimations has been deprecated please use clipAnimations instead.", true)]
766761
public bool splitAnimations

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public GUIContent GetDownloadErrorForTarget(BuildTarget target)
114114
public GUIContent enableHeadlessMode = EditorGUIUtility.TextContent("Headless Mode");
115115
public GUIContent buildScriptsOnly = EditorGUIUtility.TextContent("Scripts Only Build");
116116
public GUIContent learnAboutUnityCloudBuild = EditorGUIUtility.TextContent("Learn about Unity Cloud Build");
117-
public GUIContent compressionMethod = EditorGUIUtility.TextContent("Compression Method");
117+
public GUIContent compressionMethod = EditorGUIUtility.TextContent("Compression Method|Compression applied to Player data (scenes and resources).\nDefault - none or default platform compression.\nLZ4 - fast compression suitable for Development Builds.\nLZ4HC - higher compression rate variance of LZ4, causes longer build times. Works best for Release Builds.");
118118

119119
public Compression[] compressionTypes =
120120
{
@@ -125,7 +125,7 @@ public GUIContent GetDownloadErrorForTarget(BuildTarget target)
125125

126126
public GUIContent[] compressionStrings =
127127
{
128-
EditorGUIUtility.TextContent("None"),
128+
EditorGUIUtility.TextContent("Default"),
129129
EditorGUIUtility.TextContent("LZ4"),
130130
EditorGUIUtility.TextContent("LZ4HC"),
131131
};
@@ -751,7 +751,6 @@ void ShowBuildTargetSettings()
751751

752752
if (postprocessor.SupportsLz4Compression())
753753
{
754-
styles.compressionMethod.tooltip = "Compression method for Asset Bundles";
755754
var cmpIdx = Array.IndexOf(styles.compressionTypes, EditorUserBuildSettings.GetCompressionType(buildTargetGroup));
756755
if (cmpIdx == -1)
757756
cmpIdx = 0;

Editor/Mono/DataWatchService.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public void Dispose()
4949

5050
internal class DataWatchService : IDataWatchService
5151
{
52+
public static DataWatchService sharedInstance = new DataWatchService();
53+
5254
private HashSet<Object> m_DirtySet = new HashSet<Object>();
5355

5456
struct Spy
@@ -117,19 +119,19 @@ public void PollNativeData()
117119
}
118120
}
119121

120-
public void ProcessNotificationQueue()
122+
public void FlushDirtySet(HashSet<Object> dirty)
121123
{
122-
PollNativeData();
123-
124-
// copy because dirty call could come in while we roll along
125-
var tmpDirty = m_DirtySet;
126-
m_DirtySet = new HashSet<Object>();
124+
dirty.UnionWith(m_DirtySet);
125+
m_DirtySet.Clear();
126+
}
127127

128+
public void ProcessNotificationQueue(BaseVisualElementPanel panel, HashSet<Object> dirtySet)
129+
{
128130
// since callbacks when being invoked we make copies for safe iteration
129131
var tmpSpys = new List<Spy>();
130132

131133
// get the set of Dirties from C++ and clear it.
132-
foreach (var o in tmpDirty)
134+
foreach (var o in dirtySet)
133135
{
134136
Watchers watchers;
135137
if (m_Watched.TryGetValue(o, out watchers))
@@ -139,20 +141,18 @@ public void ProcessNotificationQueue()
139141

140142
foreach (Spy spy in tmpSpys)
141143
{
142-
if (spy.watcher.panel != null)
144+
if (spy.watcher.panel == panel)
143145
{
144146
// for any watches trigger callbacks
145147
spy.onDataChanged();
146148
}
147-
else
149+
else if (spy.watcher.panel == null)
148150
{
149151
Debug.Log("Leaking Data Spies from element: " + spy.watcher);
150152
}
151153
}
152154
}
153155
}
154-
155-
tmpDirty.Clear();
156156
}
157157

158158
static int s_WatchID;

Editor/Mono/GUIView.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ internal partial class GUIView : View
2525
internal static event Action<GUIView> positionChanged = null;
2626

2727

28-
DataWatchService s_DataWatch = new DataWatchService();
29-
3028
Panel panel
3129
{
3230
get
3331
{
34-
Panel p = UIElementsUtility.FindOrCreatePanel(GetInstanceID(), ContextType.Editor, s_DataWatch, StyleSheetResourceUtil.LoadResource);
32+
Panel p = UIElementsUtility.FindOrCreatePanel(GetInstanceID(), ContextType.Editor, DataWatchService.sharedInstance, StyleSheetResourceUtil.LoadResource);
3533
if (p.visualTree.styleSheets == null)
3634
{
3735
p.visualTree.AddStyleSheetPath("StyleSheets/DefaultCommon.uss");

Editor/Mono/ImportSettings/TextureImportPlatformSettings.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ public bool SupportsFormat(TextureImporterFormat format, TextureImporter importe
178178
case BuildTarget.WiiU:
179179
testValues = kTextureFormatsValueWiiU;
180180
break;
181+
case BuildTarget.PSP2:
182+
testValues = kTextureFormatsValuePSP2;
183+
break;
181184
// on gles mobile targets we use rgb normal maps, so we can use whatever format we want
182185
case BuildTarget.iOS:
183186
case BuildTarget.tvOS:
@@ -319,6 +322,18 @@ public void Apply()
319322
(int)TextureImporterFormat.RGBA16, // R4G4B4A4
320323
};
321324

325+
public static readonly int[] kTextureFormatsValuePSP2 =
326+
{
327+
(int)TextureImporterFormat.DXT1,
328+
(int)TextureImporterFormat.DXT5,
329+
(int)TextureImporterFormat.RGB16,
330+
(int)TextureImporterFormat.RGB24,
331+
(int)TextureImporterFormat.RGBA16,
332+
(int)TextureImporterFormat.RGBA32,
333+
(int)TextureImporterFormat.Alpha8,
334+
(int)TextureImporterFormat.RGBAHalf,
335+
};
336+
322337
public static readonly int[] kTextureFormatsValueApplePVR =
323338
{
324339
(int)TextureImporterFormat.PVRTC_RGB2,

Editor/Mono/ImportSettings/TextureImporterInspector.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ internal static int[] NormalFormatsValueAll
350350

351351
internal static string[] s_TextureFormatStringsAll;
352352
internal static string[] s_TextureFormatStringsWiiU;
353+
internal static string[] s_TextureFormatStringsPSP2;
353354
internal static string[] s_TextureFormatStringsWebGL;
354355
internal static string[] s_TextureFormatStringsApplePVR;
355356
internal static string[] s_TextureFormatStringsAndroid;
@@ -1463,6 +1464,8 @@ internal static void InitializeTextureFormatStrings()
14631464
s_TextureFormatStringsWebGL = TextureImporterInspector.BuildTextureStrings(TextureImportPlatformSettings.kTextureFormatsValueWebGL);
14641465
if (s_TextureFormatStringsWiiU == null)
14651466
s_TextureFormatStringsWiiU = TextureImporterInspector.BuildTextureStrings(TextureImportPlatformSettings.kTextureFormatsValueWiiU);
1467+
if (s_TextureFormatStringsPSP2 == null)
1468+
s_TextureFormatStringsPSP2 = TextureImporterInspector.BuildTextureStrings(TextureImportPlatformSettings.kTextureFormatsValuePSP2);
14661469
if (s_TextureFormatStringsDefault == null)
14671470
s_TextureFormatStringsDefault = TextureImporterInspector.BuildTextureStrings(TextureImportPlatformSettings.kTextureFormatsValueDefault);
14681471
if (s_NormalFormatStringsDefault == null)

Editor/Mono/Inspector/LightEditor.cs

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

191191
// Warning if GI Baking disabled and m_Lightmapping isn't realtime
192192
if (bakingWarningValue)

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);
@@ -557,13 +572,14 @@ public override void OnPreviewSettings()
557572

558573
public override void OnPreviewGUI(Rect position, GUIStyle style)
559574
{
560-
if (!ValidPreviewSetup())
575+
// Fix for case 939947 where we didn't get the Layout event if the texture was null when changing color
576+
if (!ValidPreviewSetup() && Event.current.type != EventType.ExecuteCommand)
561577
{
562578
GUILayout.BeginHorizontal();
563579
GUILayout.FlexibleSpace();
564580
Color prevColor = GUI.color;
565581
GUI.color = new Color(1, 1, 1, 0.5f);
566-
GUILayout.Label("Reflection Probe not baked yet");
582+
GUILayout.Label("Reflection Probe not baked/ready yet");
567583
GUI.color = prevColor;
568584
GUILayout.FlexibleSpace();
569585
GUILayout.EndHorizontal();

0 commit comments

Comments
 (0)