Skip to content

Commit d64a9e0

Browse files
author
Unity Technologies
committed
Unity 2018.1.0b4 C# reference source code
1 parent 1ff7751 commit d64a9e0

File tree

26 files changed

+263
-127
lines changed

26 files changed

+263
-127
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,12 @@ public override void OnPreviewGUI(Rect r, GUIStyle background)
643643
{
644644
Texture2D t = m_PreviewTextures[m_PreviewPage];
645645

646-
float oldBias = t.mipMapBias;
647646
float bias = m_MipLevel - (float)(System.Math.Log(t.width / r.width) / System.Math.Log(2));
648-
TextureUtil.SetMipMapBiasNoDirty(t, bias);
649647

650648
if (m_ShowAlpha)
651-
EditorGUI.DrawTextureAlpha(r, t, ScaleMode.ScaleToFit);
649+
EditorGUI.DrawTextureAlpha(r, t, ScaleMode.ScaleToFit, 0, bias);
652650
else
653-
EditorGUI.DrawTextureTransparent(r, t, ScaleMode.ScaleToFit);
654-
655-
TextureUtil.SetMipMapBiasNoDirty(t, oldBias);
651+
EditorGUI.DrawTextureTransparent(r, t, ScaleMode.ScaleToFit, 0, bias);
656652
}
657653
}
658654

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/AssetPipeline/TextureGenerator.bindings.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
using System;
66
using UnityEngine;
7-
using UnityEditor;
87
using UnityEngine.Bindings;
98
using System.Runtime.InteropServices;
10-
using UnityEngine.Scripting;
119
using System.Collections.Generic;
1210
using Unity.Collections;
11+
using Unity.Collections.LowLevel.Unsafe;
1312

1413
namespace UnityEditor.Experimental.AssetImporters
1514
{
@@ -81,10 +80,6 @@ public struct TextureGenerationSettings
8180
{
8281
[NativeName("assetPath")]
8382
private string m_AssetPath;
84-
[NativeName("imageData")]
85-
private IntPtr m_ImageData;
86-
[NativeName("imageDataSize")]
87-
private int m_ImageDataSize;
8883
[NativeName("qualifyForSpritePacking")]
8984
private bool m_QualifyForSpritePacking;
9085
[NativeName("enablePostProcessor")]
@@ -100,14 +95,13 @@ public struct TextureGenerationSettings
10095
[NativeName("spritePackingTag")]
10196
private string m_SpritePackingTag;
10297

98+
10399
public TextureGenerationSettings(TextureImporterType type)
104100
{
105101
m_EnablePostProcessor = true;
106102
m_AssetPath = "";
107-
m_ImageDataSize = 0;
108103
m_QualifyForSpritePacking = false;
109104
m_SpritePackingTag = "";
110-
m_ImageData = new IntPtr();
111105
m_SpriteImportData = null;
112106

113107
m_SourceTextureInformation = new SourceTextureInformation();
@@ -210,8 +204,6 @@ public TextureGenerationSettings(TextureImporterType type)
210204
}
211205

212206
public string assetPath { get { return m_AssetPath; } set { m_AssetPath = value; } }
213-
public IntPtr imageData { get { return m_ImageData; } set { m_ImageData = value; } }
214-
public int imageDataSize { get { return m_ImageDataSize; } set { m_ImageDataSize = value; } }
215207
public bool qualifyForSpritePacking { get { return m_QualifyForSpritePacking; } set { m_QualifyForSpritePacking = value; } }
216208
public bool enablePostProcessor { get { return m_EnablePostProcessor; } set { m_EnablePostProcessor = value; } }
217209
public TextureImporterSettings textureImporterSettings { get { return m_Settings; } set { m_Settings = value; } }
@@ -228,8 +220,13 @@ public TextureGenerationSettings(TextureImporterType type)
228220
[NativeHeader("Runtime/Serialize/BuildTarget.h")]
229221
public static class TextureGenerator
230222
{
223+
public static TextureGenerationOutput GenerateTexture(TextureGenerationSettings settings, NativeArray<Color32> colorBuffer)
224+
{
225+
return GenerateTextureImpl(settings, colorBuffer.GetUnsafeReadOnlyPtr(), colorBuffer.Length * 4);
226+
}
227+
231228
[NativeThrows]
232229
[NativeMethod("GenerateTextureScripting")]
233-
extern public static TextureGenerationOutput GenerateTexture(TextureGenerationSettings settings);
230+
extern static TextureGenerationOutput GenerateTextureImpl(TextureGenerationSettings settings, IntPtr colorBuffer, int colorBufferLength);
234231
}
235232
}

Editor/Mono/Collab/Views/CollabHistoryDropDown.cs

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

5-
using System.Linq;
65
using UnityEngine;
76
using UnityEngine.Experimental.UIElements;
87
using System.Collections.Generic;
@@ -12,14 +11,16 @@ namespace UnityEditor.Collaboration
1211
{
1312
internal class CollabHistoryDropDown : VisualElement
1413
{
15-
private readonly VisualElement m_FilesContainer;
16-
private readonly Label m_ToggleLabel;
17-
private int m_ChangesTotal;
14+
readonly VisualElement m_FilesContainer;
15+
readonly Label m_ToggleLabel;
16+
int m_ChangesTotal;
17+
string m_RevisionId;
1818

19-
public CollabHistoryDropDown(ICollection<ChangeData> changes, int changesTotal, bool changesTruncated)
19+
public CollabHistoryDropDown(ICollection<ChangeData> changes, int changesTotal, bool changesTruncated, string revisionId)
2020
{
2121
m_FilesContainer = new VisualElement();
2222
m_ChangesTotal = changesTotal;
23+
m_RevisionId = revisionId;
2324

2425
m_ToggleLabel = new Label(ToggleText(false));
2526
m_ToggleLabel.AddManipulator(new Clickable(ToggleDropdown));
@@ -62,10 +63,10 @@ private string ToggleText(bool open)
6263

6364
private void ShowAllClick()
6465
{
65-
var host = UnityConnect.instance.GetConfigurationURL(CloudConfigUrl.CloudCollab);
66-
var org = UnityConnect.instance.GetOrganizationForeignKey();
66+
var host = UnityConnect.instance.GetConfigurationURL(CloudConfigUrl.CloudServicesDashboard);
67+
var org = UnityConnect.instance.GetOrganizationId();
6768
var proj = UnityConnect.instance.GetProjectGUID();
68-
var url = string.Format("{0}/orgs/{1}/projects/{2}/assets", host, org, proj);
69+
var url = string.Format("{0}/collab/orgs/{1}/projects/{2}/commits?commit={3}", host, org, proj, m_RevisionId);
6970
Application.OpenURL(url);
7071
}
7172
}

Editor/Mono/Collab/Views/CollabHistoryItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public CollabHistoryItem(RevisionData data)
6969
m_Description = new Label(m_FullDescription);
7070
}
7171
m_Description.name = "RevisionDescription";
72-
var dropdown = new CollabHistoryDropDown(data.changes, data.changesTotal, data.changesTruncated);
72+
var dropdown = new CollabHistoryDropDown(data.changes, data.changesTotal, data.changesTruncated, data.id);
7373
if (data.current)
7474
{
7575
m_Button = new Button(Restore) {name = "ActionButton", text = "Restore"};

Editor/Mono/Inspector/AvatarPreview.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ private RenderTexture RenderPreviewShadowmap(Light light, float scale, Vector3 c
513513

514514
// Set ortho camera and position it
515515
var cam = previewUtility.camera;
516-
cam.orthographic = is2D;
516+
cam.orthographic = true;
517517
cam.orthographicSize = scale * 2.0f;
518518
cam.nearClipPlane = 1 * scale;
519519
cam.farClipPlane = 25 * scale;
@@ -656,7 +656,7 @@ public void DoRenderPreview(Rect previewRect, GUIStyle background)
656656

657657
// Render shadow map
658658
Matrix4x4 shadowMatrix;
659-
RenderTexture shadowMap = RenderPreviewShadowmap(previewUtility.lights[0], m_BoundingVolumeScale / 2, bodyPos, floorPos, out shadowMatrix);
659+
RenderTexture shadowMap = RenderPreviewShadowmap(previewUtility.lights[0], m_BoundingVolumeScale / 2, bodyPosition, floorPos, out shadowMatrix);
660660

661661
float tempZoomFactor = (is2D ? 1.0f : m_ZoomFactor);
662662
// Position camera

Editor/Mono/Inspector/ClothInspector.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,15 @@ void InitBrushCollider()
532532
MeshCollider oldMeshCollider = go.GetComponent<MeshCollider>();
533533
if (oldMeshCollider != null)
534534
{
535-
if (oldMeshCollider.hideFlags == (HideFlags.HideInHierarchy | HideFlags.HideInInspector))
535+
if (((oldMeshCollider.hideFlags & HideFlags.HideInHierarchy) != 0) || ((oldMeshCollider.hideFlags & HideFlags.HideInInspector) != 0))
536536
{
537-
DestroyImmediate(oldMeshCollider);
537+
DestroyImmediate(oldMeshCollider, true);
538538
}
539539
}
540540

541541
MeshCollider meshCollider = go.AddComponent<MeshCollider>();
542-
meshCollider.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
542+
meshCollider.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector |
543+
HideFlags.DontSaveInEditor | HideFlags.NotEditable;
543544

544545
meshCollider.sharedMesh = m_SkinnedMeshRenderer.sharedMesh;
545546

@@ -559,9 +560,9 @@ public void OnDestroy()
559560
MeshCollider meshCollider = go.GetComponent<MeshCollider>();
560561
if (meshCollider != null)
561562
{
562-
if (meshCollider.hideFlags == (HideFlags.HideInHierarchy | HideFlags.HideInInspector))
563+
if (((meshCollider.hideFlags & HideFlags.HideInHierarchy) != 0) || ((meshCollider.hideFlags & HideFlags.HideInInspector) != 0))
563564
{
564-
DestroyImmediate(meshCollider);
565+
DestroyImmediate(meshCollider, true);
565566
}
566567
}
567568
s_BrushCreated = false;

Editor/Mono/Inspector/MaterialPropertyDrawer.cs

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -251,41 +251,24 @@ public virtual void Apply(MaterialProperty prop)
251251
// syntax in shaders, e.g. [Toggle] in front of a shader property will
252252
// end up using MaterialToggleDrawer to display it as a toggle.
253253

254-
255-
internal class MaterialToggleDrawer : MaterialPropertyDrawer
254+
// Variant of the ToggleDrawer that defines no keyword (just UI)
255+
internal class MaterialToggleUIDrawer : MaterialPropertyDrawer
256256
{
257-
protected readonly string keyword;
258-
public MaterialToggleDrawer()
259-
{
260-
}
261-
262-
public MaterialToggleDrawer(string keyword)
257+
public MaterialToggleUIDrawer()
263258
{
264-
this.keyword = keyword;
265259
}
266260

267-
static bool IsPropertyTypeSuitable(MaterialProperty prop)
261+
public MaterialToggleUIDrawer(string keyword)
268262
{
269-
return prop.type == MaterialProperty.PropType.Float || prop.type == MaterialProperty.PropType.Range;
270263
}
271264

272265
protected virtual void SetKeyword(MaterialProperty prop, bool on)
273266
{
274-
SetKeywordInternal(prop, on, "_ON");
275267
}
276268

277-
protected void SetKeywordInternal(MaterialProperty prop, bool on, string defaultKeywordSuffix)
269+
static bool IsPropertyTypeSuitable(MaterialProperty prop)
278270
{
279-
// if no keyword is provided, use <uppercase property name> + defaultKeywordSuffix
280-
string kw = string.IsNullOrEmpty(keyword) ? prop.name.ToUpperInvariant() + defaultKeywordSuffix : keyword;
281-
// set or clear the keyword
282-
foreach (Material material in prop.targets)
283-
{
284-
if (on)
285-
material.EnableKeyword(kw);
286-
else
287-
material.DisableKeyword(kw);
288-
}
271+
return prop.type == MaterialProperty.PropType.Float || prop.type == MaterialProperty.PropType.Range;
289272
}
290273

291274
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
@@ -333,6 +316,39 @@ public override void Apply(MaterialProperty prop)
333316
}
334317
}
335318

319+
320+
internal class MaterialToggleDrawer : MaterialToggleUIDrawer
321+
{
322+
protected readonly string keyword;
323+
public MaterialToggleDrawer()
324+
{
325+
}
326+
327+
public MaterialToggleDrawer(string keyword)
328+
{
329+
this.keyword = keyword;
330+
}
331+
332+
protected override void SetKeyword(MaterialProperty prop, bool on)
333+
{
334+
SetKeywordInternal(prop, on, "_ON");
335+
}
336+
337+
protected void SetKeywordInternal(MaterialProperty prop, bool on, string defaultKeywordSuffix)
338+
{
339+
// if no keyword is provided, use <uppercase property name> + defaultKeywordSuffix
340+
string kw = string.IsNullOrEmpty(keyword) ? prop.name.ToUpperInvariant() + defaultKeywordSuffix : keyword;
341+
// set or clear the keyword
342+
foreach (Material material in prop.targets)
343+
{
344+
if (on)
345+
material.EnableKeyword(kw);
346+
else
347+
material.DisableKeyword(kw);
348+
}
349+
}
350+
}
351+
336352
// Variant of the ToggleDrawer that defines a keyword when it's not on
337353
// This is useful when adding Toggles to existing shaders while maintaining backwards compatibility
338354
internal class MaterialToggleOffDrawer : MaterialToggleDrawer

Editor/Mono/Modules/DefaultPlayerSettingsEditorExtension.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,6 @@ public virtual bool SupportsGfxJobModes()
9292
return false;
9393
}
9494

95-
public string FixTargetOSVersion(string version)
96-
{
97-
var decimalIndexes = Enumerable.Range(0, version.Length).Where(i => version[i] == '.').ToArray();
98-
99-
if (decimalIndexes.Length <= 0)
100-
return (version + ".0").Trim();
101-
else if (decimalIndexes.Length > 1)
102-
return (version.Substring(0, decimalIndexes[1])).Trim();
103-
else if (decimalIndexes.Length == 1 && decimalIndexes[0] == version.Length - 1)
104-
return (version + "0").Trim();
105-
return version.Trim();
106-
}
107-
10895
public virtual bool SupportsMultithreadedRendering()
10996
{
11097
return false;

Editor/Mono/PlayerSettingsIOS.bindings.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ public static iOSTargetOSVersion targetOSVersion
259259
}
260260
}
261261

262+
[StaticAccessor("GetPlayerSettings().GetEditorOnly()", StaticAccessorType.Dot)]
263+
[NativeMethod("GetiOSMinimumVersionString")]
264+
static extern string GetMinimumVersionString();
265+
266+
internal static readonly Version minimumOsVersion = new Version(GetMinimumVersionString());
267+
262268
[NativeProperty("iOSTargetOSVersion")]
263269
public extern static string targetOSVersionString
264270
{
@@ -544,8 +550,15 @@ internal extern static bool appleEnableProMotion
544550

545551
internal static bool IsTargetVersionEqualOrHigher(Version requiredVersion)
546552
{
547-
Version minimumVersion = new Version(8, 0);
548-
Version requestedVersion = string.IsNullOrEmpty(PlayerSettings.iOS.targetOSVersionString) ? minimumVersion : new Version(PlayerSettings.iOS.targetOSVersionString);
553+
Version requestedVersion;
554+
try
555+
{
556+
requestedVersion = new Version(targetOSVersionString);
557+
}
558+
catch (Exception)
559+
{
560+
requestedVersion = minimumOsVersion;
561+
}
549562
return requestedVersion >= requiredVersion;
550563
}
551564

0 commit comments

Comments
 (0)