Skip to content

Commit caad0c2

Browse files
author
Unity Technologies
committed
Unity 2018.2.0a5 C# reference source code
1 parent 613cc40 commit caad0c2

File tree

145 files changed

+4530
-2420
lines changed

Some content is hidden

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

145 files changed

+4530
-2420
lines changed

Editor/Mono/Animation/ZoomableArea.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ internal class ZoomableArea
2626
public bool hRangeLocked { get { return m_HRangeLocked; } set { m_HRangeLocked = value; } }
2727
public bool vRangeLocked { get { return m_VRangeLocked; } set { m_VRangeLocked = value; } }
2828

29+
// Zoom lock settings
30+
public bool hZoomLockedByDefault = false;
31+
public bool vZoomLockedByDefault = false;
2932

3033
[SerializeField] private float m_HBaseRangeMin = 0;
3134
[SerializeField] private float m_HBaseRangeMax = 1;
@@ -108,6 +111,7 @@ public float vScaleMax
108111
set { m_VScaleMax = Mathf.Clamp(value, kMinScale, kMaxScale); }
109112
}
110113

114+
111115
// Window resize settings
112116
[SerializeField] private bool m_ScaleWithWindow = false;
113117
public bool scaleWithWindow { get { return m_ScaleWithWindow; } set { m_ScaleWithWindow = value; } }
@@ -167,6 +171,8 @@ public YDirection upDirection
167171
public float rightmargin { get { return m_MarginRight; } set { m_MarginRight = value; } }
168172
public float topmargin { get { return m_MarginTop; } set { m_MarginTop = value; } }
169173
public float bottommargin { get { return m_MarginBottom; } set { m_MarginBottom = value; } }
174+
public float vSliderWidth { get { return vSlider ? styles.sliderWidth : 0f; } }
175+
public float hSliderHeight { get { return hSlider ? styles.sliderWidth : 0f; } }
170176

171177
// IDs for scrollbars
172178
int verticalScrollbarID, horizontalScrollbarID;
@@ -766,6 +772,16 @@ public void SetScaleFocused(Vector2 focalPoint, Vector2 newScale, bool lockHoriz
766772
{
767773
if (uniformScale)
768774
lockHorizontal = lockVertical = false;
775+
else
776+
{
777+
// if an axis is locked by default, it is as if that modifier key is permanently held down
778+
// actually pressing the key then lifts the lock. In other words, LockedByDefault acts like an inversion.
779+
if (hZoomLockedByDefault)
780+
lockHorizontal = !lockHorizontal;
781+
782+
if (hZoomLockedByDefault)
783+
lockVertical = !lockVertical;
784+
}
769785

770786
if (!m_HRangeLocked && !lockHorizontal)
771787
{

Editor/Mono/AssetPostprocessor.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,59 @@
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

55
using UnityEngine;
6+
using UnityEngine.Internal;
67
using UnityEngine.Scripting;
78
using System;
89
using System.Collections;
910
using System.Collections.Generic;
1011
using System.Linq;
1112
using System.Reflection;
13+
using Object = UnityEngine.Object;
1214

1315
namespace UnityEditor
1416
{
17+
// AssetPostprocessor lets you hook into the import pipeline and run scripts prior or after importing assets.
18+
public partial class AssetPostprocessor
19+
{
20+
private string m_PathName;
21+
22+
// The path name of the asset being imported.
23+
public string assetPath { get { return m_PathName; } set { m_PathName = value; } }
24+
25+
// Logs an import warning to the console.
26+
[ExcludeFromDocs]
27+
public void LogWarning(string warning)
28+
{
29+
Object context = null;
30+
LogWarning(warning, context);
31+
}
32+
33+
public void LogWarning(string warning, [DefaultValue("null")] Object context) { Debug.LogWarning(warning, context); }
34+
35+
// Logs an import error message to the console.
36+
[ExcludeFromDocs]
37+
public void LogError(string warning)
38+
{
39+
Object context = null;
40+
LogError(warning, context);
41+
}
42+
43+
public void LogError(string warning, [DefaultValue("null")] Object context) { Debug.LogError(warning, context); }
44+
45+
// Returns the version of the asset postprocessor.
46+
public virtual uint GetVersion() { return 0; }
47+
48+
// Reference to the asset importer
49+
public AssetImporter assetImporter { get { return AssetImporter.GetAtPath(assetPath); } }
50+
51+
[Obsolete("To set or get the preview, call EditorUtility.SetAssetPreview or AssetPreview.GetAssetPreview instead", true)]
52+
public Texture2D preview { get { return null; } set {} }
53+
54+
// Override the order in which importers are processed.
55+
public virtual int GetPostprocessOrder() { return 0; }
56+
57+
}
58+
1559
internal class AssetPostprocessingInternal
1660
{
1761
static void LogPostProcessorMissingDefaultConstructor(Type type)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Unity C# reference source
2+
// Copyright (c) Unity Technologies. For terms of use, see
3+
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
4+
5+
using UnityEngine.Bindings;
6+
7+
namespace UnityEditor
8+
{
9+
[NativeHeader("Editor/Src/Commands/AssetsMenuUtility.h")]
10+
internal static class AssetsMenuUtility
11+
{
12+
public static extern bool SelectionHasImmutable();
13+
}
14+
}

Editor/Mono/BuildPipeline/CodeStrippingUtils.cs

Lines changed: 21 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -33,71 +33,6 @@ static UnityType GameManagerTypeInfo
3333
}
3434
}
3535

36-
static string[] s_blackListNativeClassNames = new string[]
37-
{
38-
"Behaviour", // GetFixedBehaviourManager is directly used by fixed update in the player loop
39-
"PreloadData",
40-
// will otherwise be stripped if scene only uses default materials not explicitly referenced
41-
// (ie some components will get a default material if a material reference is null)
42-
"Material",
43-
44-
// those are used to create builtin textures and availability is checked at runtime
45-
"Cubemap",
46-
"Texture3D",
47-
"Texture2DArray",
48-
"RenderTexture",
49-
50-
"Mesh", // Used by IMGUI (even on empty projects, it draws development console & watermarks)
51-
"MeshFilter", // Used in the VR Splash screen.
52-
"MeshRenderer", // Used in the VR Splash screen.
53-
"Sprite", // Used by Unity splash screen.
54-
"LowerResBlitTexture",
55-
56-
"Transform", // well, Transform is always used
57-
"RectTransform", // Transform depends on RectTransform's TransformHierarchyChangeDispatch
58-
};
59-
60-
static UnityType[] s_blackListNativeClasses;
61-
62-
public static UnityType[] BlackListNativeClasses
63-
{
64-
get
65-
{
66-
if (s_blackListNativeClasses == null)
67-
{
68-
s_blackListNativeClasses = s_blackListNativeClassNames.Select(
69-
typeName => FindTypeByNameChecked(typeName, "code stripping blacklist native class")).ToArray();
70-
}
71-
72-
return s_blackListNativeClasses;
73-
}
74-
}
75-
76-
static readonly Dictionary<string, string> s_blackListNativeClassesDependencyNames = new Dictionary<string, string>
77-
{
78-
{"ParticleSystemRenderer", "ParticleSystem"},
79-
{"ParticleSystem", "ParticleSystemRenderer"}
80-
};
81-
82-
static Dictionary<UnityType, UnityType> s_blackListNativeClassesDependency;
83-
84-
public static Dictionary<UnityType, UnityType> BlackListNativeClassesDependency
85-
{
86-
get
87-
{
88-
if (s_blackListNativeClassesDependency == null)
89-
{
90-
s_blackListNativeClassesDependency = new Dictionary<UnityType, UnityType>();
91-
foreach (var kv in s_blackListNativeClassesDependencyNames)
92-
BlackListNativeClassesDependency.Add(
93-
FindTypeByNameChecked(kv.Key, "code stripping blacklist native class dependency key"),
94-
FindTypeByNameChecked(kv.Value, "code stripping blacklist native class dependency value"));
95-
}
96-
97-
return s_blackListNativeClassesDependency;
98-
}
99-
}
100-
10136
private static UnityType FindTypeByNameChecked(string name, string msg)
10237
{
10338
UnityType result = UnityType.FindTypeByName(name);
@@ -227,21 +162,18 @@ public static void GenerateDependencies(string strippedAssemblyDir, string icall
227162
foreach (var module in nativeModules.ToList())
228163
{
229164
var dependecies = ModuleMetadata.GetModuleDependencies(module);
230-
if (dependecies != null)
165+
foreach (var dependentModule in dependecies)
231166
{
232-
foreach (var dependentModule in dependecies)
167+
if (!nativeModules.Contains(dependentModule))
233168
{
234-
if (!nativeModules.Contains(dependentModule))
235-
{
236-
nativeModules.Add(dependentModule);
237-
didAdd = true;
238-
}
239-
if (strippingInfo != null)
240-
{
241-
var moduleName = StrippingInfo.ModuleName(module);
242-
strippingInfo.RegisterDependency(StrippingInfo.ModuleName(dependentModule), "Required by " + moduleName);
243-
strippingInfo.SetIcon("Required by " + moduleName, $"package/com.unity.modules.{module.ToLower()}");
244-
}
169+
nativeModules.Add(dependentModule);
170+
didAdd = true;
171+
}
172+
if (strippingInfo != null)
173+
{
174+
var moduleName = StrippingInfo.ModuleName(module);
175+
strippingInfo.RegisterDependency(StrippingInfo.ModuleName(dependentModule), "Required by " + moduleName);
176+
strippingInfo.SetIcon("Required by " + moduleName, $"package/com.unity.modules.{module.ToLower()}");
245177
}
246178
}
247179
}
@@ -428,19 +360,6 @@ private static HashSet<UnityType> GenerateNativeClassList(RuntimeClassRegistry r
428360
{
429361
HashSet<UnityType> nativeClasses = CollectNativeClassListFromRoots(directory, rootAssemblies, strippingInfo);
430362

431-
// Inject blacklisted native types
432-
foreach (var klass in BlackListNativeClasses)
433-
nativeClasses.Add(klass);
434-
435-
foreach (var dependent in BlackListNativeClassesDependency.Keys)
436-
{
437-
if (nativeClasses.Contains(dependent))
438-
{
439-
var provider = BlackListNativeClassesDependency[dependent];
440-
nativeClasses.Add(provider);
441-
}
442-
}
443-
444363
// List native classes found in scenes
445364
foreach (string klassName in rcr.GetAllNativeClassesIncludingManagersAsString())
446365
{
@@ -568,6 +487,14 @@ private static HashSet<string> CollectManagedTypeReferencesFromRoots(string dire
568487
return foundTypes;
569488
}
570489

490+
public class ModuleDependencyComparer : IComparer<string>
491+
{
492+
public int Compare(string stringA, string stringB)
493+
{
494+
return ModuleMetadata.GetModuleDependencies(stringA).Contains(stringB) ? 1 : ModuleMetadata.GetModuleDependencies(stringB).Contains(stringA) ? -1 : 0;
495+
}
496+
}
497+
571498
private static void WriteStaticallyLinkedModuleRegistration(TextWriter w, HashSet<string> nativeModules, HashSet<UnityType> nativeClasses)
572499
{
573500
w.WriteLine("void InvokeRegisterStaticallyLinkedModuleClasses()");
@@ -585,7 +512,9 @@ private static void WriteStaticallyLinkedModuleRegistration(TextWriter w, HashSe
585512
w.WriteLine();
586513
w.WriteLine("void RegisterStaticallyLinkedModulesGranular()");
587514
w.WriteLine("{");
588-
foreach (string module in nativeModules)
515+
516+
var nativeModulesSorted = nativeModules.OrderBy(x => x, new ModuleDependencyComparer());
517+
foreach (string module in nativeModulesSorted)
589518
{
590519
w.WriteLine("\tvoid RegisterModule_" + module + "();");
591520
w.WriteLine("\tRegisterModule_" + module + "();");

Editor/Mono/BuildPipeline/MonoAssemblyStripping.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ static void ReplaceFile(string src, string dst)
177177

178178
static public void MonoCilStrip(BuildTarget buildTarget, string managedLibrariesDirectory, string[] fileNames)
179179
{
180-
string basePath = MonoInstallationFinder.GetProfileDirectory(BuildPipeline.CompatibilityProfileToClassLibFolder(ApiCompatibilityLevel.NET_4_6), MonoInstallationFinder.MonoBleedingEdgeInstallation);
180+
// Previously requested the directory for the ApiCompatibilityLevel.NET_4_6 profile. That gets
181+
// translated to unityjit which does not contain mono-cil-strip.exe.
182+
// Per the scripting team, hardcoding to 4.5 is the correct course of action at this time.
183+
string basePath = MonoInstallationFinder.GetProfileDirectory("4.5", MonoInstallationFinder.MonoBleedingEdgeInstallation);
181184
string cilStripper = Path.Combine(basePath, "mono-cil-strip.exe");
182185

183186
foreach (string fileName in fileNames)

0 commit comments

Comments
 (0)