testss
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Unity.2D.Animation.Editor")]
|
||||
[assembly: InternalsVisibleTo("Unity.2D.SpriteShape.Editor")]
|
||||
[assembly: InternalsVisibleTo("Unity.2D.SpriteShape.EditorTests")]
|
||||
[assembly: InternalsVisibleTo("Unity.2D.PsdImporter.Editor")]
|
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "Unity.InternalAPIEditorBridge.001",
|
||||
"references": [
|
||||
"Unity.2D.Sprite.Editor"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": []
|
||||
}
|
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
using UnityEditor.U2D.Sprites;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace UnityEditor.U2D.Common
|
||||
{
|
||||
internal static class InternalEditorBridge
|
||||
{
|
||||
public static void RenderSortingLayerFields(SerializedProperty order, SerializedProperty layer)
|
||||
{
|
||||
SortingLayerEditorUtility.RenderSortingLayerFields(order, layer);
|
||||
}
|
||||
|
||||
public static void RepaintImmediately(EditorWindow window)
|
||||
{
|
||||
window.RepaintImmediately();
|
||||
}
|
||||
|
||||
public static ISpriteEditorDataProvider GetISpriteEditorDataProviderFromPath(string importedAsset)
|
||||
{
|
||||
return AssetImporter.GetAtPath(importedAsset) as ISpriteEditorDataProvider;
|
||||
}
|
||||
|
||||
public static void GenerateOutline(Texture2D texture, Rect rect, float detail, byte alphaTolerance, bool holeDetection, out Vector2[][] paths)
|
||||
{
|
||||
UnityEditor.Sprites.SpriteUtility.GenerateOutline(texture, rect, detail, alphaTolerance, holeDetection, out paths);
|
||||
}
|
||||
|
||||
public static bool DoesHardwareSupportsFullNPOT()
|
||||
{
|
||||
return ShaderUtil.hardwareSupportsFullNPOT;
|
||||
}
|
||||
|
||||
public static Texture2D CreateTemporaryDuplicate(Texture2D tex, int width, int height)
|
||||
{
|
||||
return UnityEditor.SpriteUtility.CreateTemporaryDuplicate(tex, width, height);
|
||||
}
|
||||
|
||||
public static void ShowSpriteEditorWindow(UnityEngine.Object obj = null)
|
||||
{
|
||||
SpriteUtilityWindow.ShowSpriteEditorWindow(obj);
|
||||
}
|
||||
|
||||
public static void ApplyWireMaterial()
|
||||
{
|
||||
HandleUtility.ApplyWireMaterial();
|
||||
}
|
||||
|
||||
public static void ResetSpriteEditorView(ISpriteEditor spriteEditor)
|
||||
{
|
||||
if (spriteEditor != null)
|
||||
{
|
||||
Type t = spriteEditor.GetType();
|
||||
var zoom = t.GetField("m_Zoom", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (zoom != null)
|
||||
{
|
||||
zoom.SetValue(spriteEditor, -1);
|
||||
}
|
||||
|
||||
var scrollPosition = t.GetField("m_ScrollPosition", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (scrollPosition != null)
|
||||
{
|
||||
scrollPosition.SetValue(spriteEditor, new Vector2());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ShortcutContext : IShortcutToolContext
|
||||
{
|
||||
public Func<bool> isActive;
|
||||
public bool active
|
||||
{
|
||||
get
|
||||
{
|
||||
if (isActive != null)
|
||||
return isActive();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public object context { get; set; }
|
||||
}
|
||||
|
||||
public static void RegisterShortcutContext(ShortcutContext context)
|
||||
{
|
||||
ShortcutIntegration.instance.contextManager.RegisterToolContext(context);
|
||||
}
|
||||
|
||||
public static void UnregisterShortcutContext(ShortcutContext context)
|
||||
{
|
||||
ShortcutIntegration.instance.contextManager.DeregisterToolContext(context);
|
||||
}
|
||||
|
||||
public static void AddEditorApplicationProjectLoadedCallback(UnityAction callback)
|
||||
{
|
||||
EditorApplication.projectWasLoaded += callback;
|
||||
}
|
||||
|
||||
public static void RemoveEditorApplicationProjectLoadedCallback(UnityAction callback)
|
||||
{
|
||||
EditorApplication.projectWasLoaded -= callback;
|
||||
}
|
||||
|
||||
public static string GetProjectWindowActiveFolderPath()
|
||||
{
|
||||
return ProjectWindowUtil.GetActiveFolderPath();
|
||||
}
|
||||
|
||||
public static GUIContent GetIconContent<T>() where T : UnityEngine.Object
|
||||
{
|
||||
return EditorGUIUtility.IconContent<T>();
|
||||
}
|
||||
|
||||
public static int GetAssetCreationInstanceID_ForNonExistingAssets()
|
||||
{
|
||||
return ProjectBrowser.kAssetCreationInstanceID_ForNonExistingAssets;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,193 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using System;
|
||||
using UnityEditor.Modules;
|
||||
|
||||
namespace UnityEditor.U2D.Common
|
||||
{
|
||||
|
||||
internal interface ITexturePlatformSettingsDataProvider
|
||||
{
|
||||
bool textureTypeHasMultipleDifferentValues { get; }
|
||||
TextureImporterType textureType { get; }
|
||||
SpriteImportMode spriteImportMode { get; }
|
||||
|
||||
int GetTargetCount();
|
||||
TextureImporterPlatformSettings GetPlatformTextureSettings(int i, string name);
|
||||
bool ShowPresetSettings();
|
||||
bool DoesSourceTextureHaveAlpha(int v);
|
||||
bool IsSourceTextureHDR(int v);
|
||||
void SetPlatformTextureSettings(int i, TextureImporterPlatformSettings platformSettings);
|
||||
void GetImporterSettings(int i, UnityEditor.TextureImporterSettings settings);
|
||||
}
|
||||
|
||||
internal class TexturePlatformSettings : BaseTextureImportPlatformSettings
|
||||
{
|
||||
[SerializeField]
|
||||
TextureImportPlatformSettingsData m_Data = new TextureImportPlatformSettingsData();
|
||||
ITexturePlatformSettingsDataProvider m_DataProvider;
|
||||
Func<BaseTextureImportPlatformSettings> DefaultImportSettings;
|
||||
|
||||
public override TextureImportPlatformSettingsData model
|
||||
{
|
||||
get => m_Data;
|
||||
}
|
||||
|
||||
public TexturePlatformSettings(string name, BuildTarget target, ITexturePlatformSettingsDataProvider inspector, Func<BaseTextureImportPlatformSettings> defaultPlatform) : base(name, target)
|
||||
{
|
||||
m_DataProvider = inspector;
|
||||
DefaultImportSettings = defaultPlatform;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
public override bool textureTypeHasMultipleDifferentValues
|
||||
{
|
||||
get { return m_DataProvider.textureTypeHasMultipleDifferentValues; }
|
||||
}
|
||||
|
||||
public override TextureImporterType textureType
|
||||
{
|
||||
get { return m_DataProvider.textureType; }
|
||||
}
|
||||
|
||||
public override SpriteImportMode spriteImportMode
|
||||
{
|
||||
get { return m_DataProvider.spriteImportMode; }
|
||||
}
|
||||
|
||||
public override int GetTargetCount()
|
||||
{
|
||||
return m_DataProvider.GetTargetCount();
|
||||
}
|
||||
|
||||
public override bool ShowPresetSettings()
|
||||
{
|
||||
return m_DataProvider.ShowPresetSettings();
|
||||
}
|
||||
|
||||
public override TextureImporterSettings GetImporterSettings(int i)
|
||||
{
|
||||
var textureImporterSettings = new TextureImporterSettings();
|
||||
m_DataProvider.GetImporterSettings(i, textureImporterSettings);
|
||||
return textureImporterSettings;
|
||||
}
|
||||
|
||||
public override bool IsSourceTextureHDR(int i)
|
||||
{
|
||||
return m_DataProvider.IsSourceTextureHDR(i);
|
||||
}
|
||||
|
||||
public override bool DoesSourceTextureHaveAlpha(int i)
|
||||
{
|
||||
return m_DataProvider.DoesSourceTextureHaveAlpha(i);
|
||||
}
|
||||
|
||||
public override TextureImporterPlatformSettings GetPlatformTextureSettings(int i, string name)
|
||||
{
|
||||
return m_DataProvider.GetPlatformTextureSettings(i, name);
|
||||
}
|
||||
|
||||
public override BaseTextureImportPlatformSettings GetDefaultImportSettings()
|
||||
{
|
||||
return DefaultImportSettings();
|
||||
}
|
||||
|
||||
public override void SetPlatformTextureSettings(int i, TextureImporterPlatformSettings platformSettings)
|
||||
{
|
||||
platformSettings.name = GetFixedPlatformName(platformSettings.name);
|
||||
m_DataProvider.SetPlatformTextureSettings(i, platformSettings);
|
||||
}
|
||||
|
||||
private string GetFixedPlatformName(string platform)
|
||||
{
|
||||
var targetGroup = BuildPipeline.GetBuildTargetGroupByName(platform);
|
||||
if (targetGroup != BuildTargetGroup.Unknown)
|
||||
return BuildPipeline.GetBuildTargetGroupName(targetGroup);
|
||||
return platform;
|
||||
}
|
||||
}
|
||||
|
||||
internal class TexturePlatformSettingsHelper
|
||||
{
|
||||
[SerializeField]
|
||||
List<TexturePlatformSettings> m_PlatformSettings;
|
||||
ITexturePlatformSettingsDataProvider m_DataProvider;
|
||||
|
||||
public TexturePlatformSettingsHelper(ITexturePlatformSettingsDataProvider dataProvider)
|
||||
{
|
||||
m_DataProvider = dataProvider;
|
||||
BuildPlatform[] validPlatforms = BaseTextureImportPlatformSettings.GetBuildPlayerValidPlatforms();
|
||||
|
||||
m_PlatformSettings = new List<TexturePlatformSettings>();
|
||||
m_PlatformSettings.Add(new TexturePlatformSettings(TextureImporterInspector.s_DefaultPlatformName, BuildTarget.StandaloneWindows, dataProvider, DefaulTextureImportPlatformSettings));
|
||||
|
||||
foreach (BuildPlatform bp in validPlatforms)
|
||||
m_PlatformSettings.Add(new TexturePlatformSettings(bp.name, bp.defaultTarget, dataProvider, DefaulTextureImportPlatformSettings));
|
||||
}
|
||||
|
||||
BaseTextureImportPlatformSettings DefaulTextureImportPlatformSettings()
|
||||
{
|
||||
return m_PlatformSettings[0];
|
||||
}
|
||||
|
||||
public static string defaultPlatformName { get => TextureImporterInspector.s_DefaultPlatformName; }
|
||||
|
||||
public SpriteImportMode spriteImportMode
|
||||
{
|
||||
get { return m_DataProvider.spriteImportMode; }
|
||||
}
|
||||
|
||||
public TextureImporterType textureType
|
||||
{
|
||||
get { return m_DataProvider.textureType; }
|
||||
}
|
||||
|
||||
public bool textureTypeHasMultipleDifferentValues
|
||||
{
|
||||
get { return m_DataProvider.textureTypeHasMultipleDifferentValues; }
|
||||
}
|
||||
|
||||
public void ShowPlatformSpecificSettings()
|
||||
{
|
||||
BaseTextureImportPlatformSettings.ShowPlatformSpecificSettings(m_PlatformSettings.ConvertAll<BaseTextureImportPlatformSettings>(x => x as BaseTextureImportPlatformSettings));
|
||||
SyncPlatformSettings();
|
||||
}
|
||||
|
||||
public bool HasModified()
|
||||
{
|
||||
foreach (var ps in m_PlatformSettings)
|
||||
{
|
||||
if (ps.model.HasChanged())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SyncPlatformSettings()
|
||||
{
|
||||
foreach (var ps in m_PlatformSettings)
|
||||
ps.Sync();
|
||||
}
|
||||
|
||||
public void Apply()
|
||||
{
|
||||
foreach (var ps in m_PlatformSettings)
|
||||
ps.Apply();
|
||||
}
|
||||
|
||||
public static string GetBuildTargetName(BuildTarget target)
|
||||
{
|
||||
BuildPlatform[] validPlatforms = BaseTextureImportPlatformSettings.GetBuildPlayerValidPlatforms();
|
||||
foreach (var bp in validPlatforms)
|
||||
{
|
||||
if (bp.defaultTarget == target)
|
||||
return bp.name;
|
||||
}
|
||||
return TextureImporter.defaultPlatformName;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user