mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-19 02:24:35 +08:00
add edit script button
This commit is contained in:
parent
5492c8a956
commit
22b77485c5
@ -1,7 +1,6 @@
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
using DCFApixels.DragonECS.Unity.Editors;
|
using DCFApixels.DragonECS.Unity.Editors;
|
||||||
using DCFApixels.DragonECS.Unity.Internal;
|
using DCFApixels.DragonECS.Unity.Internal;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using static PlasticGui.WebApi.Responses.CloudOrganizationHelpActionsResponse;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
{
|
{
|
||||||
@ -187,14 +188,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
Rect paddingPosition = RectUtility.AddPadding(position, Padding * 2f);
|
Rect paddingPosition = RectUtility.AddPadding(position, Padding * 2f);
|
||||||
|
|
||||||
#region Draw Component Block
|
#region Draw Component Block
|
||||||
Rect removeButtonRect = position;
|
Rect optionButton = position;
|
||||||
removeButtonRect.center -= new Vector2(0, removeButtonRect.height);
|
optionButton.center -= new Vector2(0, optionButton.height);
|
||||||
removeButtonRect.yMin = removeButtonRect.yMax;
|
optionButton.yMin = optionButton.yMax;
|
||||||
removeButtonRect.yMax += HeadIconsRect.height;
|
optionButton.yMax += HeadIconsRect.height;
|
||||||
removeButtonRect.xMin = removeButtonRect.xMax - HeadIconsRect.width;
|
optionButton.xMin = optionButton.xMax - HeadIconsRect.width;
|
||||||
removeButtonRect.center += Vector2.up * Padding * 1f;
|
optionButton.center += Vector2.up * Padding * 1f;
|
||||||
|
|
||||||
bool isRemoveComponent = EcsGUI.CloseButton(removeButtonRect);
|
bool isRemoveComponent = EcsGUI.CloseButton(optionButton);
|
||||||
|
|
||||||
if (propCount <= 0)
|
if (propCount <= 0)
|
||||||
{
|
{
|
||||||
@ -228,12 +229,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
componentRefProp.managedReferenceValue = null;
|
componentRefProp.managedReferenceValue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UnityEditorUtility.TryGetScriptAsset(componentType, out MonoScript script))
|
||||||
|
{
|
||||||
|
optionButton = HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
||||||
|
EcsGUI.ScriptAssetButton(optionButton, script);
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(description) == false)
|
if (string.IsNullOrEmpty(description) == false)
|
||||||
{
|
{
|
||||||
Rect tooltipIconRect = HeadIconsRect;
|
optionButton = HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
||||||
tooltipIconRect.center = removeButtonRect.center;
|
EcsGUI.DescriptionIcon(optionButton, description);
|
||||||
tooltipIconRect.center -= Vector2.right * tooltipIconRect.width;
|
|
||||||
EcsGUI.DescriptionIcon(tooltipIconRect, description);
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -46,10 +46,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
name = group.Name + name;
|
name = group.Name + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(description) == false)
|
|
||||||
{
|
|
||||||
name = $"{name} [i]";
|
|
||||||
}
|
|
||||||
_genericMenu.AddItem(new GUIContent(name, description), false, OnAddComponent, dummy);
|
_genericMenu.AddItem(new GUIContent(name, description), false, OnAddComponent, dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,18 +175,18 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
Color alphaPanelColor = panelColor;
|
Color alphaPanelColor = panelColor;
|
||||||
alphaPanelColor.a = EscEditorConsts.COMPONENT_DRAWER_ALPHA;
|
alphaPanelColor.a = EscEditorConsts.COMPONENT_DRAWER_ALPHA;
|
||||||
|
|
||||||
Rect removeButtonRect = GUILayoutUtility.GetLastRect();
|
Rect optionButton = GUILayoutUtility.GetLastRect();
|
||||||
|
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(alphaPanelColor));
|
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(alphaPanelColor));
|
||||||
|
|
||||||
#region Draw Component Block
|
#region Draw Component Block
|
||||||
removeButtonRect.yMin = removeButtonRect.yMax;
|
optionButton.yMin = optionButton.yMax;
|
||||||
removeButtonRect.yMax += HeadIconsRect.height;
|
optionButton.yMax += HeadIconsRect.height;
|
||||||
removeButtonRect.xMin = removeButtonRect.xMax - HeadIconsRect.width;
|
optionButton.xMin = optionButton.xMax - HeadIconsRect.width;
|
||||||
removeButtonRect.center += Vector2.up * padding * 2f;
|
optionButton.center += Vector2.up * padding * 2f;
|
||||||
|
|
||||||
bool isRemoveComponent = EcsGUI.CloseButton(removeButtonRect);
|
bool isRemoveComponent = EcsGUI.CloseButton(optionButton);
|
||||||
|
|
||||||
if (propCount <= 0)
|
if (propCount <= 0)
|
||||||
{
|
{
|
||||||
@ -213,12 +209,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
{
|
{
|
||||||
OnRemoveComponentAt(index);
|
OnRemoveComponentAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UnityEditorUtility.TryGetScriptAsset(componentType, out MonoScript script))
|
||||||
|
{
|
||||||
|
optionButton = HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
||||||
|
EcsGUI.ScriptAssetButton(optionButton, script);
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(description) == false)
|
if (string.IsNullOrEmpty(description) == false)
|
||||||
{
|
{
|
||||||
Rect tooltipIconRect = HeadIconsRect;
|
optionButton = HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
||||||
tooltipIconRect.center = removeButtonRect.center;
|
EcsGUI.DescriptionIcon(optionButton, description);
|
||||||
tooltipIconRect.center -= Vector2.right * tooltipIconRect.width;
|
|
||||||
EcsGUI.DescriptionIcon(tooltipIconRect, description);
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
BIN
src/Icons/FileIcon.png
Normal file
BIN
src/Icons/FileIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 299 B |
122
src/Icons/FileIcon.png.meta
Normal file
122
src/Icons/FileIcon.png.meta
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4f1ca6aa9d407844485856184c785946
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 11
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMasterTextureLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 0
|
||||||
|
wrapV: 0
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Server
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID:
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
spritePackingTag:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
pSDShowRemoveMatteOption: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -28,6 +28,8 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
private Texture _labelIconType;
|
private Texture _labelIconType;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Texture _labelIconMeta;
|
private Texture _labelIconMeta;
|
||||||
|
[SerializeField]
|
||||||
|
private Texture _fileIcon;
|
||||||
|
|
||||||
internal Texture HelpIcon { get { return _helpIcon; } }
|
internal Texture HelpIcon { get { return _helpIcon; } }
|
||||||
internal Texture CloseIcon { get { return _closeIcon; } }
|
internal Texture CloseIcon { get { return _closeIcon; } }
|
||||||
@ -40,6 +42,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
internal Texture VisibilityIconOff { get { return _visibilityIconOff; } }
|
internal Texture VisibilityIconOff { get { return _visibilityIconOff; } }
|
||||||
internal Texture LabelIconType { get { return _labelIconType; } }
|
internal Texture LabelIconType { get { return _labelIconType; } }
|
||||||
internal Texture LabelIconMeta { get { return _labelIconMeta; } }
|
internal Texture LabelIconMeta { get { return _labelIconMeta; } }
|
||||||
|
internal Texture FileIcon { get { return _fileIcon; } }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ MonoImporter:
|
|||||||
- _visibilityIconOff: {fileID: 2800000, guid: 1f25a5ca611092642a8ee4e08fafcd43, type: 3}
|
- _visibilityIconOff: {fileID: 2800000, guid: 1f25a5ca611092642a8ee4e08fafcd43, type: 3}
|
||||||
- _labelIconType: {fileID: 2800000, guid: 5476d6e1435981e4cbc915a080f93ee6, type: 3}
|
- _labelIconType: {fileID: 2800000, guid: 5476d6e1435981e4cbc915a080f93ee6, type: 3}
|
||||||
- _labelIconMeta: {fileID: 2800000, guid: ebb82b09315bde749a10dfa45e64067c, type: 3}
|
- _labelIconMeta: {fileID: 2800000, guid: ebb82b09315bde749a10dfa45e64067c, type: 3}
|
||||||
|
- _fileIcon: {fileID: 2800000, guid: 4f1ca6aa9d407844485856184c785946, type: 3}
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
|
@ -23,3 +23,4 @@ MonoBehaviour:
|
|||||||
_visibilityIconOff: {fileID: 2800000, guid: 1f25a5ca611092642a8ee4e08fafcd43, type: 3}
|
_visibilityIconOff: {fileID: 2800000, guid: 1f25a5ca611092642a8ee4e08fafcd43, type: 3}
|
||||||
_labelIconType: {fileID: 2800000, guid: 5476d6e1435981e4cbc915a080f93ee6, type: 3}
|
_labelIconType: {fileID: 2800000, guid: 5476d6e1435981e4cbc915a080f93ee6, type: 3}
|
||||||
_labelIconMeta: {fileID: 2800000, guid: ebb82b09315bde749a10dfa45e64067c, type: 3}
|
_labelIconMeta: {fileID: 2800000, guid: ebb82b09315bde749a10dfa45e64067c, type: 3}
|
||||||
|
_fileIcon: {fileID: 2800000, guid: 4f1ca6aa9d407844485856184c785946, type: 3}
|
@ -4,8 +4,9 @@ using System;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityObject = UnityEngine.Object;
|
using static PlasticGui.WebApi.Responses.CloudOrganizationHelpActionsResponse;
|
||||||
using UnityComponent = UnityEngine.Component;
|
using UnityComponent = UnityEngine.Component;
|
||||||
|
using UnityObject = UnityEngine.Object;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS.Unity.Editors
|
namespace DCFApixels.DragonECS.Unity.Editors
|
||||||
{
|
{
|
||||||
@ -118,8 +119,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
internal readonly static Color GreenColor = new Color32(75, 255, 0, 255);
|
internal readonly static Color GreenColor = new Color32(75, 255, 0, 255);
|
||||||
internal readonly static Color RedColor = new Color32(255, 0, 75, 255);
|
internal readonly static Color RedColor = new Color32(255, 0, 75, 255);
|
||||||
|
|
||||||
private static readonly Rect RemoveButtonRect = new Rect(0f, 0f, 19f, 19f);
|
private static readonly Rect HeadIconsRect = new Rect(0f, 0f, 19f, 19f);
|
||||||
private static readonly Rect TooltipIconRect = new Rect(0f, 0f, 19f, 19f);
|
|
||||||
|
|
||||||
public static float EntityBarHeight => EditorGUIUtility.singleLineHeight + 3f;
|
public static float EntityBarHeight => EditorGUIUtility.singleLineHeight + 3f;
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
#region small elems
|
#region small elems
|
||||||
public static void DrawIcon(Rect position, Texture icon, float iconPadding, string description)
|
public static void DrawIcon(Rect position, Texture icon, float iconPadding, string description)
|
||||||
{
|
{
|
||||||
if(position.width != position.height)
|
if (position.width != position.height)
|
||||||
{
|
{
|
||||||
Vector2 center = position.center;
|
Vector2 center = position.center;
|
||||||
float size = Mathf.Min(position.width, position.height);
|
float size = Mathf.Min(position.width, position.height);
|
||||||
@ -196,14 +196,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
public static (bool, bool) IconButtonGeneric(Rect position)
|
public static (bool, bool) IconButtonGeneric(Rect position)
|
||||||
{
|
{
|
||||||
Color dc = GUI.color;
|
using (SetAlpha(0))
|
||||||
GUI.color = Color.clear; //Хак чтобы сделать реакцию от курсора мыши без лага
|
{
|
||||||
bool result = GUI.Button(position, "", EditorStyles.miniButtonMid);
|
bool result = GUI.Button(position, string.Empty, EditorStyles.miniButtonMid);
|
||||||
GUI.color = dc;
|
|
||||||
|
|
||||||
var current = Event.current;
|
var current = Event.current;
|
||||||
return (GUI.enabled && HitTest(position, current), result);
|
return (GUI.enabled && HitTest(position, current), result);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
public static bool IconHoverScan(Rect position, Event current)
|
||||||
|
{
|
||||||
|
using (Disable) using (SetAlpha(0))
|
||||||
|
{
|
||||||
|
GUI.Button(position, string.Empty, EditorStyles.miniButtonMid);
|
||||||
|
return HitTest(position, current);
|
||||||
|
}
|
||||||
|
}
|
||||||
public static bool IconButton(Rect position, Texture icon, float iconPadding, string description)
|
public static bool IconButton(Rect position, Texture icon, float iconPadding, string description)
|
||||||
{
|
{
|
||||||
bool result = GUI.Button(position, UnityEditorUtility.GetLabel(string.Empty));
|
bool result = GUI.Button(position, UnityEditorUtility.GetLabel(string.Empty));
|
||||||
@ -217,18 +224,41 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
DrawIcon(position, Icons.Instance.HelpIcon, 0, description);
|
DrawIcon(position, Icons.Instance.HelpIcon, 0, description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static bool CloseButton(Rect position)
|
public static void ScriptAssetButton(Rect position, MonoScript script)
|
||||||
|
{
|
||||||
|
var current = Event.current;
|
||||||
|
|
||||||
|
var hover = IconHoverScan(position, current);
|
||||||
|
|
||||||
|
using (new ColorScope(new Color(1f, 1f, 1f, hover ? 1f : 0.8f)))
|
||||||
|
{
|
||||||
|
DrawIcon(position, Icons.Instance.FileIcon, hover ? 1f : 2f, "One click - Ping File. Double click - Edit Script");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hover)
|
||||||
|
{
|
||||||
|
if (current.type == EventType.MouseUp)
|
||||||
|
{
|
||||||
|
EditorGUIUtility.PingObject(script);
|
||||||
|
}
|
||||||
|
else if (current.type == EventType.MouseDown && current.clickCount >= 2)
|
||||||
|
{
|
||||||
|
AssetDatabase.OpenAsset(script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static bool CloseButton(Rect position, string description = null)
|
||||||
{
|
{
|
||||||
using (new ColorScope(new Color(1f, 1f, 1f, 0.8f)))
|
using (new ColorScope(new Color(1f, 1f, 1f, 0.8f)))
|
||||||
{
|
{
|
||||||
var (hover, click) = IconButtonGeneric(position);
|
var (hover, click) = IconButtonGeneric(position);
|
||||||
if (hover)
|
if (hover)
|
||||||
{
|
{
|
||||||
DrawIcon(position, Icons.Instance.CloseIconOn, -4f, null);
|
DrawIcon(position, Icons.Instance.CloseIconOn, -4f, description);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawIcon(position, Icons.Instance.CloseIcon, 0, null);
|
DrawIcon(position, Icons.Instance.CloseIcon, 0, description);
|
||||||
}
|
}
|
||||||
return click;
|
return click;
|
||||||
}
|
}
|
||||||
@ -560,17 +590,17 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
Color panelColor = SelectPanelColor(meta, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
|
Color panelColor = SelectPanelColor(meta, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
|
||||||
|
|
||||||
float padding = EditorGUIUtility.standardVerticalSpacing;
|
float padding = EditorGUIUtility.standardVerticalSpacing;
|
||||||
Rect removeButtonRect = GUILayoutUtility.GetLastRect();
|
Rect optionButton = GUILayoutUtility.GetLastRect();
|
||||||
|
|
||||||
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(panelColor, EscEditorConsts.COMPONENT_DRAWER_ALPHA));
|
GUILayout.BeginVertical(UnityEditorUtility.GetStyle(panelColor, EscEditorConsts.COMPONENT_DRAWER_ALPHA));
|
||||||
EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
bool isRemoveComponent = false;
|
bool isRemoveComponent = false;
|
||||||
removeButtonRect.yMin = removeButtonRect.yMax;
|
optionButton.yMin = optionButton.yMax;
|
||||||
removeButtonRect.yMax += RemoveButtonRect.height;
|
optionButton.yMax += HeadIconsRect.height;
|
||||||
removeButtonRect.xMin = removeButtonRect.xMax - RemoveButtonRect.width;
|
optionButton.xMin = optionButton.xMax - HeadIconsRect.width;
|
||||||
removeButtonRect.center += Vector2.up * padding * 2f;
|
optionButton.center += Vector2.up * padding * 2f;
|
||||||
if (CloseButton(removeButtonRect))
|
if (CloseButton(optionButton))
|
||||||
{
|
{
|
||||||
isRemoveComponent = true;
|
isRemoveComponent = true;
|
||||||
}
|
}
|
||||||
@ -590,12 +620,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (UnityEditorUtility.TryGetScriptAsset(componentType, out MonoScript script))
|
||||||
|
{
|
||||||
|
optionButton = HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
||||||
|
EcsGUI.ScriptAssetButton(optionButton, script);
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(meta.Description.Text) == false)
|
if (string.IsNullOrEmpty(meta.Description.Text) == false)
|
||||||
{
|
{
|
||||||
Rect tooltipIconRect = TooltipIconRect;
|
optionButton = HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
|
||||||
tooltipIconRect.center = removeButtonRect.center;
|
DescriptionIcon(optionButton, meta.Description.Text);
|
||||||
tooltipIconRect.center -= Vector2.right * tooltipIconRect.width;
|
|
||||||
DescriptionIcon(tooltipIconRect, meta.Description.Text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
@ -94,7 +94,6 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
return b.ToString();
|
return b.ToString();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +113,28 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
|||||||
private static GUIContent _singletonContent = null;
|
private static GUIContent _singletonContent = null;
|
||||||
private static GUIStyle _inputFieldCenterAnhor = null;
|
private static GUIStyle _inputFieldCenterAnhor = null;
|
||||||
|
|
||||||
|
private static Dictionary<Type, MonoScript> scriptsAssets = new Dictionary<Type, MonoScript>(256);
|
||||||
|
|
||||||
|
internal static bool TryGetScriptAsset(Type type, out MonoScript script)
|
||||||
|
{
|
||||||
|
if (scriptsAssets.TryGetValue(type, out script) == false)
|
||||||
|
{
|
||||||
|
script = null;
|
||||||
|
var guids = AssetDatabase.FindAssets($"{type.Name} t:MonoScript");
|
||||||
|
for (var i = 0; i < guids.Length; i++)
|
||||||
|
{
|
||||||
|
MonoScript textAsset = AssetDatabase.LoadAssetAtPath<MonoScript>(AssetDatabase.GUIDToAssetPath(guids[i]));
|
||||||
|
if (textAsset != null && textAsset.name == type.Name)
|
||||||
|
{
|
||||||
|
script = textAsset;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scriptsAssets.Add(type, script);
|
||||||
|
}
|
||||||
|
return script != null;
|
||||||
|
}
|
||||||
|
|
||||||
#region Label
|
#region Label
|
||||||
public static GUIStyle GetInputFieldCenterAnhor()
|
public static GUIStyle GetInputFieldCenterAnhor()
|
||||||
{
|
{
|
||||||
|
@ -69,6 +69,12 @@ namespace DCFApixels.DragonECS.Unity.Internal
|
|||||||
result.center += addVector;
|
result.center += addVector;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public static Rect MoveTo(in this Rect rect, Vector2 center)
|
||||||
|
{
|
||||||
|
Rect result = rect;
|
||||||
|
result.center = center;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public static Rect Move(in this Rect rect, float addX, float addY)
|
public static Rect Move(in this Rect rect, float addX, float addY)
|
||||||
{
|
{
|
||||||
return Move(rect, new Vector2(addX, addY));
|
return Move(rect, new Vector2(addX, addY));
|
||||||
|
Loading…
Reference in New Issue
Block a user