少年修仙传客户端基础资源
lwb
2020-12-14 086024060a67810d96c01ad5482b7f17795bde33
9527 窗口的控件数组化管理
6个文件已添加
356 ■■■■■ 已修改文件
Assets/Editor/ScriptEditor/BaseWindowEditor.cs 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/BaseWindowEditor.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/WindowTool.cs 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/WindowTool.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/UIPattern/CommonButton.prefab 208 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/UIPattern/CommonButton.prefab.meta 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/ScriptEditor/BaseWindowEditor.cs
New file
@@ -0,0 +1,84 @@
using UnityEngine;
using UnityEditor;
using Snxxz.UI;
using UnityEditorInternal;
[CustomEditor(typeof(Window), true)]
public class BaseWindowEditor : Editor
{
    ReorderableList list;
    void OnEnable()
    {
        var serProp = this.serializedObject.FindProperty("widgets");
        this.list = new ReorderableList(serProp.serializedObject, serProp, true, true, true, true);
        this.list.drawHeaderCallback = this.OnDrawListHeader;
        this.list.drawElementCallback = this.OnDrawListElement;
        this.list.onAddCallback = this.OnAddCallback;
    }
    void OnDrawListHeader(Rect rect)
    {
        var spacing = 10f;
        var arect = rect;
        arect.height = EditorGUIUtility.singleLineHeight;
        arect.x += 15;
        arect.width = 200;
        EditorGUI.LabelField(arect, "Name");
        arect.x += arect.width + spacing;
        arect.width = 200;
        EditorGUI.LabelField(arect, "GameObject");
    }
    void OnAddCallback(ReorderableList list)
    {
        if (list.serializedProperty != null)
        {
            list.serializedProperty.arraySize++;
            list.index = list.serializedProperty.arraySize - 1;
            SerializedProperty itemData = list.serializedProperty.GetArrayElementAtIndex(list.index);
            var namePop = itemData.FindPropertyRelative("name");
            namePop.stringValue = null;
            var goPop = itemData.FindPropertyRelative("gameObject");
            goPop.objectReferenceValue = null;
        }
        else
        {
            ReorderableList.defaultBehaviours.DoAddButton(list);
        }
    }
    void OnDrawListElement(Rect rect, int index, bool isActive, bool isFocused)
    {
        var spacing = 10f;
        var arect = rect;
        var element = this.list.serializedProperty.GetArrayElementAtIndex(index);
        var nameProperty = element.FindPropertyRelative("name");
        var goProperty = element.FindPropertyRelative("gameObject");
        arect.height = EditorGUIUtility.singleLineHeight;
        arect.width = 200;
        if (goProperty.objectReferenceValue != null && string.IsNullOrEmpty(nameProperty.stringValue))
            nameProperty.stringValue = EditorGUI.TextField(arect, goProperty.objectReferenceValue.name);
        else
            nameProperty.stringValue = EditorGUI.TextField(arect, nameProperty.stringValue);
        arect.x += arect.width + spacing;
        arect.width = 200;
        EditorGUI.PropertyField(arect, goProperty, GUIContent.none);
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        this.serializedObject.Update();
        var property = list.serializedProperty;
        property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, property.displayName);
        if (property.isExpanded)
        {
            this.list.DoLayoutList();
        }
        this.serializedObject.ApplyModifiedProperties();
    }
}
Assets/Editor/ScriptEditor/BaseWindowEditor.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9be54e150201ea346845c924aa785bfa
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Editor/Tool/WindowTool.cs
New file
@@ -0,0 +1,35 @@
using UnityEngine;
using UnityEditor;
using Snxxz.UI;
public class WindowTool : EditorWindow
{
    [MenuItem("Tools/窗口管理")]
    public static void ShowWindow()
    {
        EditorWindow.GetWindow<WindowTool>("窗口管理").Show();
    }
    [SerializeField]
    private string windowName;
    private void OnGUI()
    {
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("窗口名称");
        windowName = GUILayout.TextField(windowName, GUILayout.MinWidth(300));
        if (GUILayout.Button("打开"))
        {
            OpenWindow();
        }
    }
    private void OpenWindow()
    {
        if (string.IsNullOrEmpty(windowName) || !Application.isPlaying)
            return;
        WindowCenter.Instance.Open(windowName);
    }
}
Assets/Editor/Tool/WindowTool.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0ffa879fdcf968945bf689cad86029e5
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Editor/UIPattern/CommonButton.prefab
New file
@@ -0,0 +1,208 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2154807644928535534
GameObject:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  serializedVersion: 6
  m_Component:
  - component: {fileID: 6799213541382060757}
  - component: {fileID: 8829747232368733922}
  - component: {fileID: 1751265100431819983}
  - component: {fileID: 5654609980340474327}
  m_Layer: 0
  m_Name: CommonButton
  m_TagString: Untagged
  m_Icon: {fileID: 0}
  m_NavMeshLayer: 0
  m_StaticEditorFlags: 0
  m_IsActive: 1
--- !u!224 &6799213541382060757
RectTransform:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 2154807644928535534}
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 0, z: 0}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_Children:
  - {fileID: 8818173244328049919}
  m_Father: {fileID: 0}
  m_RootOrder: 0
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
  m_AnchorMin: {x: 0, y: 0.5}
  m_AnchorMax: {x: 0, y: 0.5}
  m_AnchoredPosition: {x: 134, y: -231}
  m_SizeDelta: {x: 163, y: 64}
  m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8829747232368733922
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 2154807644928535534}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 4b71190bf06931745ae72221994579ef, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  m_Navigation:
    m_Mode: 3
    m_SelectOnUp: {fileID: 0}
    m_SelectOnDown: {fileID: 0}
    m_SelectOnLeft: {fileID: 0}
    m_SelectOnRight: {fileID: 0}
  m_Transition: 1
  m_Colors:
    m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
    m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
    m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
    m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
    m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
    m_ColorMultiplier: 1
    m_FadeDuration: 0.1
  m_SpriteState:
    m_HighlightedSprite: {fileID: 0}
    m_PressedSprite: {fileID: 0}
    m_SelectedSprite: {fileID: 0}
    m_DisabledSprite: {fileID: 0}
  m_AnimationTriggers:
    m_NormalTrigger: Normal
    m_HighlightedTrigger: Highlighted
    m_PressedTrigger: Pressed
    m_SelectedTrigger: Selected
    m_DisabledTrigger: Disabled
  m_Interactable: 1
  m_TargetGraphic: {fileID: 5654609980340474327}
  m_OnClick:
    m_PersistentCalls:
      m_Calls: []
  interval: 0
  customPositiveSound: 0
  customNegativeSound: 0
  positiveSound: 0
  negativeSound: 0
--- !u!222 &1751265100431819983
CanvasRenderer:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 2154807644928535534}
  m_CullTransparentMesh: 0
--- !u!114 &5654609980340474327
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 2154807644928535534}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 5eec31867c0c74f4aa2eeade969eec0e, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  m_Material: {fileID: 0}
  m_Color: {r: 1, g: 1, b: 1, a: 1}
  m_RaycastTarget: 1
  m_Maskable: 1
  m_OnCullStateChanged:
    m_PersistentCalls:
      m_Calls: []
  m_Sprite: {fileID: 21300000, guid: ea7870ff8b962f046802bad588d5cfd5, type: 3}
  m_Type: 0
  m_PreserveAspect: 0
  m_FillCenter: 1
  m_FillMethod: 4
  m_FillAmount: 1
  m_FillClockwise: 1
  m_FillOrigin: 0
  m_UseSpriteMesh: 0
  m_PixelsPerUnitMultiplier: 1
  m_Gray: 0
  m_IconKey:
--- !u!1 &5934364636793223519
GameObject:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  serializedVersion: 6
  m_Component:
  - component: {fileID: 8818173244328049919}
  - component: {fileID: 3214953141854913601}
  - component: {fileID: 6835816125174184761}
  m_Layer: 0
  m_Name: TextEx
  m_TagString: Untagged
  m_Icon: {fileID: 0}
  m_NavMeshLayer: 0
  m_StaticEditorFlags: 0
  m_IsActive: 1
--- !u!224 &8818173244328049919
RectTransform:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 5934364636793223519}
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
  m_LocalPosition: {x: 0, y: 0, z: 0}
  m_LocalScale: {x: 1, y: 1, z: 1}
  m_Children: []
  m_Father: {fileID: 6799213541382060757}
  m_RootOrder: 0
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
  m_AnchorMin: {x: 0, y: 0}
  m_AnchorMax: {x: 1, y: 1}
  m_AnchoredPosition: {x: 0, y: 0}
  m_SizeDelta: {x: 0, y: 0}
  m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3214953141854913601
CanvasRenderer:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 5934364636793223519}
  m_CullTransparentMesh: 0
--- !u!114 &6835816125174184761
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 5934364636793223519}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 8c90b724ae1ce3c4495afe6ba6005ae0, type: 3}
  m_Name:
  m_EditorClassIdentifier:
  m_Material: {fileID: 0}
  m_Color: {r: 0.2509804, g: 0.10980392, b: 0.023529412, a: 1}
  m_RaycastTarget: 1
  m_Maskable: 1
  m_OnCullStateChanged:
    m_PersistentCalls:
      m_Calls: []
  m_FontData:
    m_Font: {fileID: 12800000, guid: 8dc6445b1c0b84d4fbf1147740d43a4e, type: 3}
    m_FontSize: 30
    m_FontStyle: 0
    m_BestFit: 0
    m_MinSize: 2
    m_MaxSize: 40
    m_Alignment: 4
    m_AlignByGeometry: 0
    m_RichText: 1
    m_HorizontalOverflow: 0
    m_VerticalOverflow: 0
    m_LineSpacing: 1
  m_Text: "\u901A\u7528\u6309\u94AE"
  m_IsKey: 0
  m_ColorType: 7
Assets/Editor/UIPattern/CommonButton.prefab.meta
New file
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 960a293e74d282541ac558708842f34b
PrefabImporter:
  externalObjects: {}
  userData:
  assetBundleName:
  assetBundleVariant: