Skip to content

Commit 623fbfa

Browse files
author
Unity Technologies
committed
Unity 2018.2.0a6 C# reference source code
1 parent caad0c2 commit 623fbfa

File tree

178 files changed

+6575
-1929
lines changed

Some content is hidden

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

178 files changed

+6575
-1929
lines changed

Editor/Mono/Animation/EditorCurveBinding.bindings.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace UnityEditor
1313
{
1414
[NativeType(CodegenOptions.Custom, "MonoEditorCurveBinding")]
15-
public struct EditorCurveBinding
15+
public struct EditorCurveBinding : IEquatable<EditorCurveBinding>
1616
{
1717
// The path of the game object / bone being animated.
1818
public string path;
@@ -64,10 +64,12 @@ public override int GetHashCode()
6464

6565
public override bool Equals(object other)
6666
{
67-
if (!(other is EditorCurveBinding)) return false;
67+
return other is EditorCurveBinding && Equals((EditorCurveBinding)other);
68+
}
6869

69-
EditorCurveBinding rhs = (EditorCurveBinding)other;
70-
return this == rhs;
70+
public bool Equals(EditorCurveBinding other)
71+
{
72+
return this == other;
7173
}
7274

7375
public Type type

Editor/Mono/Animation/TimeArea.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public void TimeRuler(Rect position, float frameRate, bool labels, bool useEntir
199199
// stuff drawn with both GUI and Handles/GL. Otherwise things are off by one pixel half the time.
200200

201201
float labelpos = Mathf.Floor(FrameToPixel(frame, frameRate, position));
202-
string label = FormatTime(labelTicks[i], frameRate, timeFormat);
202+
string label = FormatTickTime(labelTicks[i], frameRate, timeFormat);
203203
GUI.Label(new Rect(labelpos + 3, -3, 40, 20), label, timeAreaStyles.timelineTick);
204204
}
205205
}
@@ -504,6 +504,11 @@ public string FormatTime(float time, float frameRate, TimeFormat timeFormat)
504504
}
505505
}
506506

507+
public virtual string FormatTickTime(float time, float frameRate, TimeFormat timeFormat)
508+
{
509+
return FormatTime(time, frameRate, timeFormat);
510+
}
511+
507512
public string FormatValue(float value)
508513
{
509514
int vDecimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(shownArea.height / drawRect.height);

Editor/Mono/AssetDatabase/AssetDatabaseSearching.cs

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// Copyright (c) Unity Technologies. For terms of use, see
33
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
44

5+
using System;
6+
using System.Linq;
57
using System.Collections.Generic;
68
using UnityEngine;
7-
9+
using Object = UnityEngine.Object;
810

911
namespace UnityEditor
1012
{
@@ -27,33 +29,39 @@ public static string[] FindAssets(string filter, string[] searchInFolders)
2729

2830
private static string[] FindAssets(SearchFilter searchFilter)
2931
{
30-
if (searchFilter.folders != null && searchFilter.folders.Length > 0)
31-
return SearchInFolders(searchFilter);
32-
return SearchAllAssets(searchFilter);
32+
return FindAllAssets(searchFilter).Select(property => property.guid).ToArray();
3333
}
3434

35-
private static string[] SearchAllAssets(SearchFilter searchFilter)
35+
internal static IEnumerable<HierarchyProperty> FindAllAssets(SearchFilter searchFilter)
3636
{
37-
var property = new HierarchyProperty(HierarchyType.Assets);
38-
property.SetSearchFilter(searchFilter);
39-
property.Reset();
40-
var guids = new List<string>();
41-
while (property.Next(null))
42-
{
43-
guids.Add(property.guid);
44-
}
45-
return guids.ToArray();
37+
var enumerator = EnumerateAllAssets(searchFilter);
38+
while (enumerator.MoveNext())
39+
yield return enumerator.Current;
40+
}
41+
42+
internal static IEnumerator<HierarchyProperty> EnumerateAllAssets(SearchFilter searchFilter)
43+
{
44+
if (searchFilter.folders != null && searchFilter.folders.Length > 0)
45+
return FindInFolders(searchFilter, p => p);
46+
47+
return FindEverywhere(searchFilter, p => p);
4648
}
4749

48-
private static string[] SearchInFolders(SearchFilter searchFilter)
50+
private static IEnumerator<T> FindInFolders<T>(SearchFilter searchFilter, Func<HierarchyProperty,T> selector)
4951
{
50-
var property = new HierarchyProperty(HierarchyType.Assets);
51-
var guids = new List<string>();
5252
foreach (string folderPath in searchFilter.folders)
5353
{
54+
var folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folderPath);
55+
var rootPath = "Assets";
56+
57+
var pathComponents = folderPath.Split('/');
58+
// Find the right rootPath if folderPath is part of a package
59+
if (pathComponents.Length > 1 && pathComponents[0] == UnityEditor.PackageManager.Folders.GetPackagesMountPoint())
60+
rootPath = pathComponents[0] + "/" + pathComponents[1];
61+
5462
// Set empty filter to ensure we search all assets to find folder
63+
var property = new HierarchyProperty(rootPath);
5564
property.SetSearchFilter(new SearchFilter());
56-
int folderInstanceID = GetMainAssetInstanceID(folderPath);
5765
if (property.Find(folderInstanceID, null))
5866
{
5967
// Set filter after we found the folder
@@ -62,15 +70,30 @@ private static string[] SearchInFolders(SearchFilter searchFilter)
6270
int[] expanded = null; // enter all children of folder
6371
while (property.NextWithDepthCheck(expanded, folderDepth + 1))
6472
{
65-
guids.Add(property.guid);
73+
yield return selector(property);
6674
}
6775
}
6876
else
6977
{
7078
Debug.LogWarning("AssetDatabase.FindAssets: Folder not found: '" + folderPath + "'");
7179
}
7280
}
73-
return guids.ToArray();
81+
}
82+
83+
private static IEnumerator<T> FindEverywhere<T>(SearchFilter searchFilter, Func<HierarchyProperty, T> selector)
84+
{
85+
var rootPaths = new List<string>();
86+
rootPaths.Add("Assets");
87+
rootPaths.AddRange(UnityEditor.PackageManager.Folders.GetPackagesPaths());
88+
foreach (var rootPath in rootPaths)
89+
{
90+
var property = new HierarchyProperty(rootPath);
91+
property.SetSearchFilter(searchFilter);
92+
while (property.Next(null))
93+
{
94+
yield return selector(property);
95+
}
96+
}
7497
}
7598
}
7699
}

Editor/Mono/AssetPipeline/AssetImportContext.bindings.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,31 @@ public void AddObjectToAsset(string identifier, Object obj)
5252
// Create a dependency against the contents of the source asset at the provided path
5353
// * if the asset at the path changes, it will trigger an import
5454
// * if the asset at the path moves, it will trigger an import
55-
internal void DependOnHashOfSourceFile(string path)
55+
internal void DependsOnSourceAsset(string path)
5656
{
5757
if (string.IsNullOrEmpty(path))
5858
{
59-
throw new ArgumentNullException("path", "Cannot add a null path");
59+
throw new ArgumentNullException("path", "Cannot add dependency on invalid path.");
6060
}
6161

62-
DependOnHashOfSourceFileInternal(path);
62+
DependsOnSourceAssetInternal(path);
6363
}
6464

65-
[NativeName("DependOnHashOfSourceFile")]
66-
private extern void DependOnHashOfSourceFileInternal(string path);
65+
[NativeName("DependsOnSourceAsset")]
66+
private extern void DependsOnSourceAssetInternal(string path);
67+
68+
internal void DependsOnImportedAsset(string path)
69+
{
70+
if (string.IsNullOrEmpty(path))
71+
{
72+
throw new ArgumentNullException("path", "Cannot add dependency on invalid path.");
73+
}
74+
75+
DependsOnImportedAssetInternal(path);
76+
}
77+
78+
[NativeName("DependsOnImportedAsset")]
79+
private extern void DependsOnImportedAssetInternal(string path);
6780

6881
// Internal for now, will be made public once UI/UX for persistent importer logs is implemented.
6982
public void LogImportError(string msg, UnityEngine.Object obj = null)

Editor/Mono/AssetPostprocessor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@
1111
using System.Linq;
1212
using System.Reflection;
1313
using Object = UnityEngine.Object;
14+
using UnityEditor.Experimental.AssetImporters;
1415

1516
namespace UnityEditor
1617
{
1718
// AssetPostprocessor lets you hook into the import pipeline and run scripts prior or after importing assets.
1819
public partial class AssetPostprocessor
1920
{
2021
private string m_PathName;
22+
private AssetImportContext m_Context;
2123

2224
// The path name of the asset being imported.
2325
public string assetPath { get { return m_PathName; } set { m_PathName = value; } }
2426

27+
// The context of the import, used to specify dependencies
28+
public AssetImportContext context { get { return m_Context; } internal set { m_Context = value; } }
29+
2530
// Logs an import warning to the console.
2631
[ExcludeFromDocs]
2732
public void LogWarning(string warning)
@@ -182,7 +187,7 @@ static ArrayList GetCachedAssetPostprocessorClasses()
182187
}
183188

184189
[RequiredByNativeCode]
185-
static void InitPostprocessors(string pathName)
190+
static void InitPostprocessors(AssetImportContext context, string pathName)
186191
{
187192
m_ImportProcessors = new ArrayList();
188193

@@ -194,6 +199,7 @@ static void InitPostprocessors(string pathName)
194199
{
195200
var assetPostprocessor = Activator.CreateInstance(assetPostprocessorClass) as AssetPostprocessor;
196201
assetPostprocessor.assetPath = pathName;
202+
assetPostprocessor.context = context;
197203
m_ImportProcessors.Add(assetPostprocessor);
198204
}
199205
catch (MissingMethodException)

Editor/Mono/Audio/Mixer/GUI/AudioMixerWindow.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ List<AudioMixerController> GetAllControllers()
255255
static List<AudioMixerController> FindAllAudioMixerControllers()
256256
{
257257
var result = new List<AudioMixerController>();
258-
var prop = new HierarchyProperty(HierarchyType.Assets);
259-
prop.SetSearchFilter(new SearchFilter() { classNames = new[] { "AudioMixerController" } });
260-
while (prop.Next(null))
258+
foreach (var prop in AssetDatabase.FindAllAssets(new SearchFilter() { classNames = new[] { "AudioMixerController" } }))
261259
{
262260
var controller = prop.pptrValue as AudioMixerController;
263261
if (controller)
@@ -768,8 +766,8 @@ internal class AssetSelectionPopupMenu
768766
static public void Show(Rect buttonRect, string[] classNames, int initialSelectedInstanceID)
769767
{
770768
var menu = new GenericMenu();
771-
var objs = FindAssetsOfType(classNames);
772769

770+
var objs = AssetDatabase.FindAllAssets(new SearchFilter() { classNames = classNames }).Select(property => property.pptrValue).ToList();
773771
if (objs.Any())
774772
{
775773
objs.Sort((result1, result2) => EditorUtility.NaturalCompare(result1.name, result2.name));
@@ -793,17 +791,5 @@ static void SelectCallback(object userData)
793791
if (obj != null)
794792
Selection.activeInstanceID = obj.GetInstanceID();
795793
}
796-
797-
static List<UnityEngine.Object> FindAssetsOfType(string[] classNames)
798-
{
799-
var prop = new HierarchyProperty(HierarchyType.Assets);
800-
prop.SetSearchFilter(new SearchFilter() { classNames = classNames });
801-
var objs = new List<UnityEngine.Object>();
802-
while (prop.Next(null))
803-
{
804-
objs.Add(prop.pptrValue);
805-
}
806-
return objs;
807-
}
808794
}
809795
}

Editor/Mono/Audio/Mixer/GUI/TreeViewForAudioMixerGroups.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,8 @@ public override void FetchData()
238238

239239
List<int> allowedInstanceIDs = ObjectSelector.get.allowedInstanceIDs;
240240

241-
HierarchyProperty prop = new HierarchyProperty(HierarchyType.Assets);
242-
prop.SetSearchFilter(new SearchFilter() {classNames = new[] {"AudioMixerController"}});
243241
var controllers = new List<AudioMixerController>();
244-
while (prop.Next(null))
242+
foreach (var prop in AssetDatabase.FindAllAssets(new SearchFilter() { classNames = new[] { "AudioMixerController" } }))
245243
{
246244
var controller = prop.pptrValue as AudioMixerController;
247245
if (ShouldShowController(controller, allowedInstanceIDs))

Editor/Mono/BuildPipeline/AssemblyStripper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ private static string GetMethodPreserveBlacklistContents(RuntimeClassRegistry rc
298298
foreach (var assembly in groupedByAssembly)
299299
{
300300
var assemblyName = assembly.Key;
301-
sb.AppendLine(string.Format("\t<assembly fullname=\"{0}\">", assemblyName));
301+
sb.AppendLine(string.Format("\t<assembly fullname=\"{0}\" ignoreIfMissing=\"1\">", assemblyName));
302302
var groupedByType = assembly.GroupBy(m => m.fullTypeName);
303303
foreach (var type in groupedByType)
304304
{

Editor/Mono/BuildPipeline/DesktopStandalonePostProcessor.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public override void PostProcess(BuildPostProcessArgs args)
3333
throw new OperationCanceledException();
3434

3535
CopyStagingAreaIntoDestination(args, filesToNotOverwrite);
36+
37+
ProcessSymbolFiles(args);
3638
}
3739
catch (OperationCanceledException)
3840
{
@@ -59,8 +61,6 @@ public override void UpdateBootConfig(BuildTarget target, BootConfigData config,
5961

6062
if (PlayerSettings.forceSingleInstance)
6163
config.AddKey("single-instance");
62-
if (EditorApplication.scriptingRuntimeVersion == ScriptingRuntimeVersion.Latest)
63-
config.Set("scripting-runtime-version", "latest");
6464
if (IL2CPPUtils.UseIl2CppCodegenWithMonoBackend(BuildPipeline.GetBuildTargetGroup(target)))
6565
config.Set("mono-codegen", "il2cpp");
6666
}
@@ -494,6 +494,10 @@ protected virtual void ProcessPlatformSpecificIL2CPPOutput(BuildPostProcessArgs
494494
{
495495
}
496496

497+
protected virtual void ProcessSymbolFiles(BuildPostProcessArgs args)
498+
{
499+
}
500+
497501
protected string GetIl2CppDataBackupFolderName(BuildPostProcessArgs args)
498502
{
499503
return Path.GetFileNameWithoutExtension(args.installPath) + "_BackUpThisFolder_ButDontShipItWithYourGame";

Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using PackageInfo = Unity.DataContract.PackageInfo;
2121
using System.Xml.Linq;
2222
using System.Xml.XPath;
23-
using UnityEditor.Experimental.Build.Player;
23+
using UnityEditor.Build.Player;
2424

2525
namespace UnityEditorInternal
2626
{

0 commit comments

Comments
 (0)