Skip to content

Commit

Permalink
fix optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlong committed May 24, 2021
1 parent 5f817c2 commit 9b423cb
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 13 deletions.
5 changes: 3 additions & 2 deletions UnityProject/Assets/HotUnity/Editor/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static Texture2D scriptIcon
{
get
{
_icon = null;
if (_icon == null)
{
_icon = GetBase64Texture(ICON_FIRE_COLORFUL);
Expand All @@ -28,8 +29,8 @@ private static Texture2D GetBase64Texture(string base64Str)
return texture;
}

static Color proColor = (Color)new Color32(56, 56, 56, 255);
static Color plebColor = (Color)new Color32(194, 194, 194, 255);
static Color proColor = new Color32(56, 56, 56, 255);
static Color plebColor = new Color32(194, 194, 194, 255);

public static Color backgroudColor
{
Expand Down
11 changes: 7 additions & 4 deletions UnityProject/Assets/HotUnity/Editor/HotFieldGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public static class HotFieldGUI

public static HotScriptAdapter.CacheInfo EditorDrawField(Type type, HotScriptAdapter.CacheInfo info)
{
/**
* string, bool, short, int, long, float, double,
*/
var title = Helper.ToTitle(info.fieldName);
if (info.typeName == typeof(string).FullName)
{
Expand All @@ -22,13 +25,13 @@ public static HotScriptAdapter.CacheInfo EditorDrawField(Type type, HotScriptAda
}
else if (type.IsClass && typeof(Component).IsAssignableFrom(type))
{
info.componentValue = (Component)EditorGUILayout.ObjectField(title, info.componentValue, type);
info.componentValue = (Component)EditorGUILayout.ObjectField(title, info.componentValue, type, true);
}
else if (type.IsClass && hotScriptType.IsAssignableFrom(type))
{
var tempComp = (Component)EditorGUILayout.ObjectField(title, info.componentValue, typeof(HotScriptAdapter));
if (tempComp != null && tempComp is HotScriptAdapter
&& ((HotScriptAdapter)tempComp).targetClass == type.FullName)
var tempComp = (HotScriptAdapter)EditorGUILayout.ObjectField(title,
info.componentValue, typeof(HotScriptAdapter), true);
if (tempComp != null && (tempComp).targetClass == type.FullName)
{
info.componentValue = tempComp;
}
Expand Down
30 changes: 29 additions & 1 deletion UnityProject/Assets/HotUnity/HotScriptAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,34 @@ namespace HotUnity
public class HotScriptAdapter : MonoBehaviour
{
public string targetClass;
public object targetObj;

public string[] strings;
public bool[] bools;
public char[] chars;
public short[] shorts;
public int[] ints;
public float[] floats;
public double[] doubles;
public int[] enums;
public Vector2[] vector2s;
public Vector2Int[] vector2Ints;
public Vector3[] vector3s;
public Vector3Int[] vector3Ints;
public Vector4[] vector4s;
public RangeInt[] rangeInts;
public Quaternion[] quaternions;
public Rect[] rects;
public RectInt[] rectInts;
public Matrix4x4[] matrix4X4s;
public Bounds[] bounds;
public BoundsInt[] boundsInts;
public Color[] colors;
public Color32[] color32s;
public Component[] components;
public HotScriptAdapter[] adapters;

public int[][] intss;


public CacheInfo[] cacheInfos;

Expand All @@ -23,6 +50,7 @@ public struct CacheInfo
public Component componentValue;
}

public object targetObj { get; set; }
void Awake()
{
InvokeMethod(nameof(Awake));
Expand Down
58 changes: 52 additions & 6 deletions UnityProject/Assets/Resources/Test.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GameObject:
- component: {fileID: 2208871440416432558}
- component: {fileID: 6122346705257189045}
- component: {fileID: 3154642046317467005}
- component: {fileID: 7277715309099585504}
- component: {fileID: 2435387432901263737}
m_Layer: 0
m_Name: Image
m_TagString: Untagged
Expand Down Expand Up @@ -73,7 +73,7 @@ MonoBehaviour:
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!114 &7277715309099585504
--- !u!114 &2435387432901263737
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand Down Expand Up @@ -223,7 +223,7 @@ GameObject:
- component: {fileID: 1037683787797942776}
- component: {fileID: 7238677793919117003}
- component: {fileID: 3642581602781590632}
- component: {fileID: 3675687587722284917}
- component: {fileID: 7569051268861022667}
m_Layer: 0
m_Name: Test
m_TagString: Untagged
Expand All @@ -249,7 +249,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 1}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &7238677793919117003
Expand All @@ -265,10 +265,33 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
targetClass: HotProject.TestBasic
strings: []
bools:
chars:
shorts:
ints:
floats: []
doubles: []
enums:
vector2s: []
vector2Ints: []
vector3s: []
vector3Ints: []
vector4s: []
quaternions: []
rects: []
rectInts: []
matrix4X4s: []
bounds: []
boundsInts: []
colors: []
color32s: []
components: []
adapters: []
cacheInfos:
- fieldName: testText
typeName: System.String
intValue: 0
intValue: 2
floatValue: 0
vector3Value: {x: 0, y: 0, z: 0}
stringValue: "\u54D4\u54E9\u54D4\u54E9 (\u309C-\u309C)\u3064\u30ED \u5E72\u676F~"
Expand All @@ -293,6 +316,29 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
targetClass: HotProject.TestRefer
strings: []
bools:
chars:
shorts:
ints:
floats: []
doubles: []
enums:
vector2s: []
vector2Ints: []
vector3s: []
vector3Ints: []
vector4s: []
quaternions: []
rects: []
rectInts: []
matrix4X4s: []
bounds: []
boundsInts: []
colors: []
color32s: []
components: []
adapters: []
cacheInfos:
- fieldName: image
typeName: UnityEngine.UI.Image
Expand All @@ -315,7 +361,7 @@ MonoBehaviour:
vector3Value: {x: 0, y: 0, z: 0}
stringValue:
componentValue: {fileID: 7238677793919117003}
--- !u!114 &3675687587722284917
--- !u!114 &7569051268861022667
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand Down

0 comments on commit 9b423cb

Please sign in to comment.