Skip to content

Commit 3225c11

Browse files
author
Unity Technologies
committed
Unity 2018.2.1f1 C# reference source code
1 parent 48d4a3b commit 3225c11

8 files changed

Lines changed: 67 additions & 8 deletions

File tree

Editor/Mono/AssetPipeline/TextureImporter.bindings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,9 @@ public void SetTextureSettings(TextureImporterSettings src)
358358

359359
// Read texture import instructions into [[TextureImportInstructions]] class.
360360
public extern void ReadTextureImportInstructions(BuildTarget target, out TextureFormat desiredFormat, out ColorSpace colorSpace, out int compressionQuality);
361+
362+
// This is pure backward compatibility codepath. It can be removed when we decide that the time has come
363+
internal extern bool ShouldShowRemoveMatteOption();
364+
internal extern bool removeMatte { get; set; }
361365
}
362366
}

Editor/Mono/ImportSettings/TextureImporterInspector.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,11 @@ internal class Styles
561561

562562
public readonly GUIContent showAdvanced = EditorGUIUtility.TrTextContent("Advanced", "Show advanced settings.");
563563

564+
public readonly GUIContent psdRemoveMatte = EditorGUIUtility.TrTextContent("Remove Matte (PSD)", "Enable special processing for PSD that has transparency, as color pixels will be tweaked (blended with white color).");
565+
public readonly GUIContent psdRemoveMatteWarning = EditorGUIUtility.TrTextContent("If you have PSD with transparency, colors will be tweaked by blending them with white color. Matte removal refers to our attempts to undo that, and this is deprecated.");
566+
public readonly GUIContent psdRemoveMatteURLButton = EditorGUIUtility.TrTextContent("How to handle PSD with alpha");
567+
public readonly string psdRemoveMatteURL = "https://docs.unity3d.com/Manual/HOWTO-alphamaps.html";
568+
564569
public Styles()
565570
{
566571
// This is far from ideal, but it's better than having tons of logic in the GUI code itself.
@@ -641,6 +646,7 @@ void EnumPopup(SerializedProperty property, System.Type type, GUIContent label)
641646
SerializedProperty m_SpriteGenerateFallbackPhysicsShape;
642647

643648
SerializedProperty m_AlphaIsTransparency;
649+
SerializedProperty m_PSDRemoveMatte;
644650

645651
SerializedProperty m_TextureShape;
646652

@@ -702,6 +708,7 @@ void CacheSerializedProperties()
702708
m_SpriteGenerateFallbackPhysicsShape = serializedObject.FindProperty("m_SpriteGenerateFallbackPhysicsShape");
703709

704710
m_AlphaIsTransparency = serializedObject.FindProperty("m_AlphaIsTransparency");
711+
m_PSDRemoveMatte = serializedObject.FindProperty("m_PSDRemoveMatte");
705712

706713
m_TextureType = serializedObject.FindProperty("m_TextureType");
707714
m_TextureShape = serializedObject.FindProperty("m_TextureShape");
@@ -1110,6 +1117,21 @@ void AlphaHandlingGUI(TextureInspectorGUIElement guiElements)
11101117
ToggleFromInt(m_AlphaIsTransparency, s_Styles.alphaIsTransparency);
11111118
}
11121119
}
1120+
1121+
// This is pure backward compatibility codepath. It can be removed when we decide that the time has come
1122+
TextureImporter importer = target as TextureImporter;
1123+
if (importer.ShouldShowRemoveMatteOption())
1124+
{
1125+
EditorGUILayout.PropertyField(m_PSDRemoveMatte, s_Styles.psdRemoveMatte);
1126+
if (m_PSDRemoveMatte.boolValue)
1127+
{
1128+
GUILayout.BeginVertical();
1129+
EditorGUILayout.HelpBox(s_Styles.psdRemoveMatteWarning.text, MessageType.Warning, true);
1130+
if (EditorGUILayout.LinkLabel(s_Styles.psdRemoveMatteURLButton))
1131+
Application.OpenURL(s_Styles.psdRemoveMatteURL);
1132+
GUILayout.EndVertical();
1133+
}
1134+
}
11131135
}
11141136

11151137
private bool ShouldShowSpriteMeshTypeOption()

Editor/Mono/Inspector/LightEditor.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class Styles
6868
public readonly GUIContent LightmappingMode = EditorGUIUtility.TrTextContent("Mode", "Specifies the light mode used to determine if and how a light will be baked. Possible modes are Baked, Mixed, and Realtime.");
6969
public readonly GUIContent LightBounceIntensity = EditorGUIUtility.TrTextContent("Indirect Multiplier", "Controls the intensity of indirect light being contributed to the scene. A value of 0 will cause Realtime lights to be removed from realtime global illumination and Baked and Mixed lights to no longer emit indirect lighting. Has no effect when both Realtime and Baked Global Illumination are disabled.");
7070
public readonly GUIContent ShadowType = EditorGUIUtility.TrTextContent("Shadow Type", "Specifies whether Hard Shadows, Soft Shadows, or No Shadows will be cast by the light.");
71+
public readonly GUIContent CastShadows = EditorGUIUtility.TrTextContent("Cast Shadows", "Specifies whether Soft Shadows or No Shadows will be cast by the light.");
7172
//realtime
7273
public readonly GUIContent ShadowRealtimeSettings = EditorGUIUtility.TrTextContent("Realtime Shadows", "Settings for realtime direct shadows.");
7374
public readonly GUIContent ShadowStrength = EditorGUIUtility.TrTextContent("Strength", "Controls how dark the shadows cast by the light will be.");
@@ -376,7 +377,20 @@ public void ApplyModifiedProperties()
376377
public void DrawShadowsType()
377378
{
378379
EditorGUILayout.Space();
379-
EditorGUILayout.PropertyField(shadowsType, s_Styles.ShadowType);
380+
if (light.type == LightType.Area)
381+
{
382+
EditorGUI.BeginChangeCheck();
383+
bool shadows = EditorGUILayout.Toggle(s_Styles.CastShadows, shadowsType.intValue != (int)LightShadows.None);
384+
if (EditorGUI.EndChangeCheck())
385+
{
386+
Undo.RecordObject(light, "Adjust Shadow Type");
387+
shadowsType.intValue = shadows ? (int)LightShadows.Soft : (int)LightShadows.None;
388+
}
389+
}
390+
else
391+
{
392+
EditorGUILayout.PropertyField(shadowsType, s_Styles.ShadowType);
393+
}
380394
}
381395

382396
public void DrawBakedShadowRadius()

Editor/Mono/PackageUtility.bindings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ internal class PackageUtility
6060
public static extern ExportPackageItem[] BuildExportPackageItemsList(string[] guids, bool dependencies);
6161
[NativeThrows]
6262
public static extern void ExportPackage(string[] guids, string fileName);
63+
[NativeThrows]
64+
public static extern void ExportPackageAndPackageManagerManifest(string[] guids, string fileName);
6365
public static extern ImportPackageItem[] ExtractAndPrepareAssetList(string packagePath, out string packageIconPath, out bool canPerformReInstall);
6466

6567
[FreeFunction("DelayedImportPackageAssets")]

Editor/Mono/Scripting/ScriptCompilation/EditorCompilation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ internal bool CompileScriptAssemblies(ScriptAssembly[] scriptAssemblies, ScriptA
879879
// Copy from tempBuildDirectory to assembly output directory
880880
if (!CopyAssembly(AssetPath.Combine(tempBuildDirectory, assembly.Filename), assembly.FullPath))
881881
{
882-
messages.Add(new CompilerMessage { message = string.Format("Copying assembly from directory {0} to {1} failed", tempBuildDirectory, assembly.OutputDirectory), type = CompilerMessageType.Error, file = assembly.FullPath, line = -1, column = -1 });
882+
messages.Add(new CompilerMessage { message = string.Format("Copying assembly from '{0}' to '{1}' failed", AssetPath.Combine(tempBuildDirectory, assembly.Filename), assembly.FullPath), type = CompilerMessageType.Error, file = assembly.FullPath, line = -1, column = -1 });
883883
StopCompilationTask();
884884
InvokeAssemblyCompilationFinished(assemblyOutputPath, messages);
885885
return;

Editor/Mono/SpriteEditor/SpriteEditorWindow.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private class SpriteEditorWindowStyles
6868

6969
private IMGUIContainer m_ToolbarIMGUIElement;
7070
private IMGUIContainer m_MainViewIMGUIElement;
71+
private VisualElement m_ModuleViewElement;
7172
private VisualElement m_MainViewElement;
7273

7374
[SerializeField]
@@ -244,7 +245,13 @@ private void SetupVisualElements()
244245
{
245246
name = "spriteEditorWindowMainView",
246247
};
248+
m_ModuleViewElement = new VisualElement()
249+
{
250+
name = "moduleViewElement",
251+
pickingMode = PickingMode.Ignore
252+
};
247253
m_MainViewElement.Add(m_MainViewIMGUIElement);
254+
m_MainViewElement.Add(m_ModuleViewElement);
248255
var root = this.GetRootVisualContainer();
249256
root.AddStyleSheetPath("StyleSheets/SpriteEditor/SpriteEditor.uss");
250257
root.Add(m_ToolbarIMGUIElement);
@@ -637,7 +644,7 @@ void SetupModule(int newModuleIndex)
637644
if (s_Instance == null)
638645
return;
639646

640-
m_MainViewIMGUIElement.Clear();
647+
m_ModuleViewElement.Clear();
641648
if (m_RegisteredModules.Count > newModuleIndex)
642649
{
643650
m_CurrentModuleIndex = newModuleIndex;
@@ -652,8 +659,8 @@ void SetupModule(int newModuleIndex)
652659
}
653660
if (m_MainViewElement != null)
654661
m_MainViewElement.Dirty(ChangeType.Repaint);
655-
if (m_MainViewIMGUIElement != null)
656-
m_MainViewIMGUIElement.Dirty(ChangeType.Repaint);
662+
if (m_ModuleViewElement != null)
663+
m_ModuleViewElement.Dirty(ChangeType.Repaint);
657664
}
658665

659666
void UpdateAvailableModules()
@@ -804,7 +811,7 @@ public SpriteRect selectedSpriteRect
804811
m_MainViewElement.Dirty(ChangeType.Repaint);
805812
using (var e = SpriteSelectionChangeEvent.GetPooled())
806813
{
807-
e.target = m_MainViewIMGUIElement;
814+
e.target = m_ModuleViewElement;
808815
UIElementsUtility.eventDispatcher.DispatchEvent(e, m_MainViewElement.panel);
809816
}
810817
}
@@ -893,7 +900,7 @@ public T GetDataProvider<T>() where T : class
893900

894901
public VisualElement GetMainVisualContainer()
895902
{
896-
return m_MainViewIMGUIElement;
903+
return m_ModuleViewElement;
897904
}
898905

899906
static internal void OnTextureReimport(string path)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Unity 2018.2.0f2 C# reference source code
1+
## Unity 2018.2.1f1 C# reference source code
22

33
The C# part of the Unity engine and editor source code.
44
May be used for reference purposes only.

Runtime/2D/SpriteAtlas/ScriptBindings/SpriteAtlas.bindings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ private static bool RequestAtlas(string tag)
2828
return false;
2929
}
3030

31+
public static event Action<SpriteAtlas> atlasRegistered = null;
32+
33+
[RequiredByNativeCode]
34+
private static void PostRegisteredAtlas(SpriteAtlas spriteAtlas)
35+
{
36+
atlasRegistered?.Invoke(spriteAtlas);
37+
}
38+
3139
extern internal static void Register(SpriteAtlas spriteAtlas);
3240
}
3341

@@ -42,6 +50,8 @@ public class SpriteAtlas : UnityEngine.Object
4250
extern public string tag { get; }
4351
extern public int spriteCount { get; }
4452

53+
extern public bool CanBindTo(Sprite sprite);
54+
4555
extern public Sprite GetSprite(string name);
4656
public int GetSprites(Sprite[] sprites) { return GetSpritesScripting(sprites); }
4757
public int GetSprites(Sprite[] sprites, string name) { return GetSpritesWithNameScripting(sprites, name); }

0 commit comments

Comments
 (0)