Skip to content

Commit 3412229

Browse files
author
Unity Technologies
committed
Unity 2017.3.0a7 C# reference source code
1 parent a519a91 commit 3412229

File tree

130 files changed

+3454
-1523
lines changed

Some content is hidden

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

130 files changed

+3454
-1523
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ public bool HandlePlatformSettings(BuildTarget buildTarget, List<TextureImporter
135135
buildTarget == BuildTarget.iOS ||
136136
buildTarget == BuildTarget.tvOS ||
137137
buildTarget == BuildTarget.Android ||
138-
buildTarget == BuildTarget.Tizen ||
139-
buildTarget == BuildTarget.SamsungTV
138+
buildTarget == BuildTarget.Tizen
140139
;
141140

142141
if (showAsEnum)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ public void AcquireTextureFormatValuesAndStrings(BuildTarget buildTarget, out in
1818
formatValues = TextureImportPlatformSettings.kTextureFormatsValueApplePVR;
1919
formatStrings = TextureImporterInspector.s_TextureFormatStringsApplePVR;
2020
}
21-
else if (buildTarget == BuildTarget.SamsungTV)
22-
{
23-
formatValues = TextureImportPlatformSettings.kTextureFormatsValueSTV;
24-
formatStrings = TextureImporterInspector.s_TextureFormatStringsSTV;
25-
}
2621
else
2722
{
2823
formatValues = TextureImportPlatformSettings.kTextureFormatsValueAndroid;

Editor/Mono/Annotation/SceneFXWindow.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private class Styles
2121

2222
public override Vector2 GetWindowSize()
2323
{
24-
var windowHeight = 2f * kFrameWidth + EditorGUI.kSingleLineHeight * 5;
24+
var windowHeight = 2f * kFrameWidth + EditorGUI.kSingleLineHeight * 6;
2525
var windowSize = new Vector2(160, windowHeight);
2626
return windowSize;
2727
}
@@ -84,6 +84,9 @@ private void Draw(Rect rect)
8484

8585
DrawListElement(drawPos, "Image Effects", state.showImageEffects, value => state.showImageEffects = value);
8686
drawPos.y += EditorGUI.kSingleLineHeight;
87+
88+
DrawListElement(drawPos, "Particle Systems", state.showParticleSystems, value => state.showParticleSystems = value);
89+
drawPos.y += EditorGUI.kSingleLineHeight;
8790
}
8891

8992
void DrawListElement(Rect rect, string toggleName, bool value, Action<bool> setValue)

Editor/Mono/AssemblyInfo/AssemblyInfo.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
[assembly: InternalsVisibleTo("UnityEditor.AppleTV.Extensions")]
2323
[assembly: InternalsVisibleTo("UnityEditor.Android.Extensions")]
2424
[assembly: InternalsVisibleTo("UnityEditor.Tizen.Extensions")]
25-
[assembly: InternalsVisibleTo("UnityEditor.SamsungTV.Extensions")]
2625
[assembly: InternalsVisibleTo("UnityEditor.XboxOne.Extensions")]
2726
[assembly: InternalsVisibleTo("UnityEditor.PSP2.Extensions")]
2827
[assembly: InternalsVisibleTo("UnityEditor.PS4.Extensions")]

Editor/Mono/AssetPipeline/ModelImporter.bindings.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,26 @@ public enum ClipAnimationMaskType
2424
None = 3
2525
}
2626

27-
[NativeHeader("Runtime/Animation/AvatarMask.h")]
28-
[StructLayoutAttribute(LayoutKind.Sequential)]
27+
[UsedByNativeCode]
28+
[NativeType(CodegenOptions = CodegenOptions.Custom, Header = "Runtime/Animation/AvatarMask.h", IntermediateScriptingStructName = "MonoTransformMaskElement")]
29+
[NativeHeader("Editor/Src/AssetPipeline/ModelImporting/ModelImporter.bindings.h")]
2930
internal partial struct TransformMaskElement
3031
{
3132
public string path;
3233
public float weight;
3334
}
3435

36+
[UsedByNativeCode]
3537
[NativeType(CodegenOptions = CodegenOptions.Custom, IntermediateScriptingStructName = "MonoClipAnimationInfoCurve")]
3638
[NativeHeader("Editor/Src/AssetPipeline/ModelImporting/ModelImporter.bindings.h")]
37-
[StructLayoutAttribute(LayoutKind.Sequential)]
39+
[StructLayout(LayoutKind.Sequential)]
3840
public partial struct ClipAnimationInfoCurve
3941
{
4042
public string name;
4143
public AnimationCurve curve;
4244
}
4345

46+
[UsedByNativeCode]
4447
[System.Serializable]
4548
[StructLayout(LayoutKind.Sequential)]
4649
[NativeType(CodegenOptions = CodegenOptions.Custom, IntermediateScriptingStructName = "MonoClipAnimationInfo")]
@@ -319,6 +322,7 @@ public enum ModelImporterHumanoidOversampling
319322
X8 = 8
320323
}
321324

325+
[UsedByNativeCode]
322326
[NativeType(Header = "Editor/Src/Animation/HumanTemplate.h")]
323327
public sealed partial class HumanTemplate : Object
324328
{

Editor/Mono/AssetPipeline/ScriptedImporter.cs

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ namespace UnityEditor.Experimental.AssetImporters
1414
{
1515
// Class concept: helper class that holds a generated asset object, during the import phase of scripted importer.
1616
//
17-
// Motivation: A source asset file can produce multiple assets (a main one and multple sub assets). Needed a way to genericaly hold these sub assets of the source Asset.
17+
// Motivation: A source asset file can produce multiple objects. Needed a way to generically hold these objects and keep track of which one is the main object.
1818
class ImportedObject
1919
{
2020
// Is this the main part of the asset being imported?
21-
public bool mainAsset { get; set; }
21+
public bool mainAssetObject { get; set; }
2222

23-
public Object asset { get; set; }
23+
public Object obj { get; set; }
2424

25-
// Unique identifier, within imported asset context, of asset
26-
public string identifier { get; set; }
25+
public string localIdentifier { get; set; }
2726

2827
public Texture2D thumbnail { get; set; }
2928
}
@@ -33,70 +32,62 @@ public class AssetImportContext
3332
public string assetPath { get; internal set; }
3433
public BuildTarget selectedBuildTarget { get; internal set; }
3534

36-
List<ImportedObject> m_SubAssets = new List<ImportedObject>();
37-
internal List<ImportedObject> subAssets
35+
List<ImportedObject> m_ImportedObjects = new List<ImportedObject>();
36+
internal List<ImportedObject> importedObjects
3837
{
39-
get { return m_SubAssets; }
38+
get { return m_ImportedObjects; }
4039
}
4140

4241
internal AssetImportContext()
4342
{
4443
}
4544

46-
// Adds an asset object to the resulting asset list and tags it as the main asset.
47-
// A minimum and a maximum of one asset must be tagged as the main asset.
48-
// param identifier: Unique identifier, within the source asset, that remains the same accross re-import events of the given source asset file.
49-
public void SetMainAsset(string identifier, Object asset)
45+
public void SetMainObject(Object obj)
5046
{
51-
AddAsset(true, identifier, asset, null);
52-
}
47+
if (obj == null)
48+
return;
5349

54-
// Adds an asset object to the resulting asset list and tags it as the main asset.
55-
// A minimum and a maximum of one asset must be tagged as the main asset.
56-
// param identifier: Unique identifier, within the source asset, that remains the same accross re-import events of the given source asset file.
57-
public void SetMainAsset(string identifier, Object asset, Texture2D thumbnail)
58-
{
59-
AddAsset(true, identifier, asset, thumbnail);
60-
}
50+
var mainObject = m_ImportedObjects.FirstOrDefault(x => x.mainAssetObject);
51+
if (mainObject != null)
52+
{
53+
if (mainObject.obj == obj)
54+
return;
6155

62-
// Adds a sub asset object to the resulting asset list, that is Not the main asset.
63-
// param identifier: Unique identifier, within the source asset, that remains the same accross re-import events of the given source asset file.
64-
public void AddSubAsset(string identifier, Object asset)
65-
{
66-
AddAsset(false, identifier, asset, null);
56+
Debug.LogWarning(string.Format(@"An object was already set as the main object: ""{0}"" conflicting on ""{1}""", assetPath, mainObject.localIdentifier));
57+
mainObject.mainAssetObject = false;
58+
}
59+
60+
mainObject = m_ImportedObjects.FirstOrDefault(x => x.obj == obj);
61+
if (mainObject == null)
62+
{
63+
throw new Exception("Before an object can be set as main, it must first be added using AddObjectToAsset.");
64+
}
65+
66+
mainObject.mainAssetObject = true;
67+
m_ImportedObjects.Remove(mainObject);
68+
m_ImportedObjects.Insert(0, mainObject);
6769
}
6870

69-
// Adds a sub asset object to the resulting asset list, that is Not the main asset.
70-
// param identifier: Unique identifier, within the source asset, that remains the same accross re-import events of the given source asset file.
71-
public void AddSubAsset(string identifier, Object asset, Texture2D thumbnail)
71+
public void AddObjectToAsset(string identifier, Object obj)
7272
{
73-
AddAsset(false, identifier, asset, thumbnail);
73+
AddObjectToAsset(identifier, obj, null);
7474
}
7575

76-
void AddAsset(bool main, string identifier, Object asset, Texture2D thumbnail)
76+
public void AddObjectToAsset(string identifier, Object obj, Texture2D thumbnail)
7777
{
78-
if (asset == null)
78+
if (obj == null)
7979
{
80-
throw new ArgumentNullException("asset", "Cannot add a null asset : " + (identifier ?? "<null>"));
81-
}
82-
83-
var mainAsset = m_SubAssets.FirstOrDefault(x => x.mainAsset);
84-
if (main && mainAsset != null)
85-
{
86-
throw new Exception(String.Format(@"A Main asset has already been added and only one is allowed: ""{0}"" conflicting on ""{1}"" and ""{2}""", assetPath, mainAsset.identifier, identifier));
80+
throw new ArgumentNullException("obj", "Cannot add a null object : " + (identifier ?? "<null>"));
8781
}
8882

8983
var desc = new ImportedObject()
9084
{
91-
mainAsset = main,
92-
identifier = identifier,
93-
asset = asset,
85+
mainAssetObject = false,
86+
localIdentifier = identifier,
87+
obj = obj,
9488
thumbnail = thumbnail
9589
};
96-
if (main)
97-
m_SubAssets.Insert(0, desc);
98-
else
99-
m_SubAssets.Add(desc);
90+
m_ImportedObjects.Add(desc);
10091
}
10192
}
10293

@@ -135,14 +126,11 @@ ImportResult GenerateAssetData(ImportRequest request)
135126

136127
OnImportAsset(ctx);
137128

138-
if (!ctx.subAssets.Any((x) => x.mainAsset))
139-
throw new Exception("Import failed/rejected as none of the sub assets was set as the 'main asset':" + ctx.assetPath);
140-
141129
var result = new ImportResult
142130
{
143-
m_Assets = ctx.subAssets.Select(x => x.asset).ToArray(),
144-
m_AssetNames = ctx.subAssets.Select(x => x.identifier).ToArray(),
145-
m_Thumbnails = ctx.subAssets.Select(x => x.thumbnail).ToArray()
131+
m_Assets = ctx.importedObjects.Select(x => x.obj).ToArray(),
132+
m_AssetNames = ctx.importedObjects.Select(x => x.localIdentifier).ToArray(),
133+
m_Thumbnails = ctx.importedObjects.Select(x => x.thumbnail).ToArray()
146134
};
147135

148136
return result;

Editor/Mono/BuildPipeline/BuildPlatform.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public BuildTarget defaultTarget
6767
return BuildTarget.WebGL;
6868
case BuildTargetGroup.WSA:
6969
return BuildTarget.WSAPlayer;
70-
case BuildTargetGroup.SamsungTV:
71-
return BuildTarget.SamsungTV;
7270
case BuildTargetGroup.Facebook:
7371
return BuildTarget.StandaloneWindows64;
7472
default:
@@ -109,7 +107,6 @@ internal BuildPlatforms()
109107
buildPlatformsList.Add(new BuildPlatform("Wii U", "BuildSettings.WiiU", BuildTargetGroup.WiiU, false));
110108
buildPlatformsList.Add(new BuildPlatform("Universal Windows Platform", "BuildSettings.Metro", BuildTargetGroup.WSA, true));
111109
buildPlatformsList.Add(new BuildPlatform("WebGL", "BuildSettings.WebGL", BuildTargetGroup.WebGL, true));
112-
buildPlatformsList.Add(new BuildPlatform("Samsung TV", "BuildSettings.SamsungTV", BuildTargetGroup.SamsungTV, true));
113110
buildPlatformsList.Add(new BuildPlatform("Nintendo 3DS", "BuildSettings.N3DS", BuildTargetGroup.N3DS, false));
114111
buildPlatformsList.Add(new BuildPlatform("Facebook", "BuildSettings.Facebook", BuildTargetGroup.Facebook, true));
115112
buildPlatformsList.Add(new BuildPlatform("Nintendo Switch", "BuildSettings.Switch", BuildTargetGroup.Switch, false));

Editor/Mono/BuildPlayerSceneTreeView.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected override TreeViewItem BuildRoot()
6161
List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>(EditorBuildSettings.scenes);
6262
foreach (var sc in scenes)
6363
{
64-
var item = new BuildPlayerSceneTreeViewItem(sc.path.GetHashCode(), 0, sc.path, sc.enabled);
64+
var item = new BuildPlayerSceneTreeViewItem(sc.guid.GetHashCode(), 0, sc.path, sc.enabled);
6565
root.AddChild(item);
6666
}
6767
return root;
@@ -99,7 +99,9 @@ protected override void RowGUI(RowGUIArgs args)
9999
var sceneItem = args.item as BuildPlayerSceneTreeViewItem;
100100
if (sceneItem != null)
101101
{
102-
var sceneExists = File.Exists(sceneItem.fullName);
102+
var sceneWasDeleted = sceneItem.guid.Empty();
103+
var sceneExists = !sceneWasDeleted && File.Exists(sceneItem.fullName);
104+
103105
using (new EditorGUI.DisabledScope(!sceneExists))
104106
{
105107
var newState = sceneItem.active;
@@ -124,12 +126,17 @@ protected override void RowGUI(RowGUIArgs args)
124126

125127
EditorBuildSettings.scenes = GetSceneList();
126128
}
129+
127130
base.RowGUI(args);
128131

129132
if (sceneItem.counter != BuildPlayerSceneTreeViewItem.kInvalidCounter)
130133
{
131134
TreeView.DefaultGUI.LabelRightAligned(args.rowRect, "" + sceneItem.counter, args.selected, args.focused);
132135
}
136+
else if (sceneItem.displayName == string.Empty || !sceneExists)
137+
{
138+
TreeView.DefaultGUI.LabelRightAligned(args.rowRect, "Deleted", args.selected, args.focused);
139+
}
133140
}
134141
}
135142
else
@@ -192,7 +199,8 @@ protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
192199
{
193200
if (AssetDatabase.GetMainAssetTypeAtPath(path) == typeof(SceneAsset))
194201
{
195-
selection.Add(path.GetHashCode());
202+
var guid = new GUID(AssetDatabase.AssetPathToGUID(path));
203+
selection.Add(guid.GetHashCode());
196204

197205
bool unique = true;
198206
foreach (var scene in scenes)

Editor/Mono/BuildPlayerWindow.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class Styles
6868
{ EditorGUIUtility.TextContent("Your license does not cover Wii U Publishing."), EditorGUIUtility.TextContent("Contact sales"), new GUIContent(kMailURL) },
6969
{ EditorGUIUtility.TextContent("Your license does not cover Universal Windows Platform Publishing."), EditorGUIUtility.TextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
7070
{ EditorGUIUtility.TextContent("Your license does not cover Windows Phone 8 Publishing."), EditorGUIUtility.TextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
71-
{ EditorGUIUtility.TextContent("Your license does not cover SamsungTV Publishing"), EditorGUIUtility.TextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
7271
{ EditorGUIUtility.TextContent("Your license does not cover Nintendo 3DS Publishing"), EditorGUIUtility.TextContent("Contact sales"), new GUIContent(kMailURL) },
7372
{ EditorGUIUtility.TextContent("Your license does not cover Facebook Publishing"), EditorGUIUtility.TextContent("Go to Our Online Store"), new GUIContent(kShopURL) },
7473
{ EditorGUIUtility.TextContent("Your license does not cover Nintendo Switch Publishing"), EditorGUIUtility.TextContent("Contact sales"), new GUIContent(kMailURL) },
@@ -88,7 +87,6 @@ class Styles
8887
{ EditorGUIUtility.TextContent("Wii U Player is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
8988
{ EditorGUIUtility.TextContent("Universal Windows Platform Player is not supported in\nthis build.\n\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
9089
{ EditorGUIUtility.TextContent("Windows Phone 8 Player is not supported\nin this build.\n\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
91-
{ EditorGUIUtility.TextContent("SamsungTV Player is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
9290
{ EditorGUIUtility.TextContent("Nintendo 3DS is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
9391
{ EditorGUIUtility.TextContent("Facebook is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
9492
{ EditorGUIUtility.TextContent("Nintendo Switch is not supported in this build.\nDownload a build that supports it."), null, new GUIContent(kDownloadURL) },
@@ -492,7 +490,6 @@ static bool IsColorSpaceValid(BuildPlatform platform)
492490
RegexOptions.Compiled);
493491
static Dictionary<string, string> s_ModuleNames = new Dictionary<string, string>()
494492
{
495-
{ "SamsungTV", "Samsung-TV" },
496493
{ "tvOS", "AppleTV" },
497494
{ "OSXStandalone", "Mac" },
498495
{ "WindowsStandalone", "Windows" },
@@ -847,7 +844,7 @@ private static void GUIBuildButtons(IBuildWindowExtension buildWindowExtension,
847844
GUI.enabled = enableBuildButton;
848845
if (GUILayout.Button(buildButton, GUILayout.Width(Styles.kButtonWidth)))
849846
{
850-
CallBuildMethods(true, BuildOptions.ShowBuiltPlayer);
847+
CallBuildMethods(true, BuildOptions.ShowBuiltPlayer | BuildOptions.StrictMode);
851848
GUIUtility.ExitGUI();
852849
}
853850
// Build and Run button

Editor/Mono/ConsoleWindow.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ public static void Init()
8989
StatusLog = new GUIStyle("CN StatusInfo");
9090
CountBadge = new GUIStyle("CN CountBadge");
9191

92+
// If the console window isn't open OnEnable() won't trigger so it will end up with 0 lines,
93+
// so we always make sure we read it up when we initialize here.
94+
LogStyleLineCount = EditorPrefs.GetInt("ConsoleWindowLogLineCount", 2);
95+
9296
UpdateLogStyleFixedHeights();
9397
}
9498

0 commit comments

Comments
 (0)