<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      自定義類(lèi)

      [System.Serializable]
      public class Test 
      {
          public string name;
          public int age;
      }

      數(shù)據(jù)類(lèi)

      using System.Collections.Generic;
      using UnityEngine;
      [CreateAssetMenu]
      public class TestSO : ScriptableObject
      {
          public List<Test> testList;
      }

      顯示如下

       

      修改數(shù)據(jù)類(lèi)顯示

      數(shù)據(jù)元素內(nèi)容顯示為一行

      注意:不能使用自動(dòng)布局api

      using UnityEngine;
      using UnityEditor;
      [CustomPropertyDrawer(typeof(Test))]
      public class TestDrawer : PropertyDrawer
      {
          public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
          {
              var spName = property.FindPropertyRelative("name");
              var spAge = property.FindPropertyRelative("age");
      
              var rect1 = position;
              var rect2 = position;
      
              var indentlevel = EditorGUI.indentLevel;
              var lableWidth = EditorGUIUtility.labelWidth;
              EditorGUI.indentLevel = 2;
              EditorGUIUtility.labelWidth = 60;
      
              rect1.width = position.width / 2;
              rect1.height = EditorGUIUtility.singleLineHeight;
      
              rect2.width = position.width / 2;
              rect2.height = EditorGUIUtility.singleLineHeight;
      
              rect2.x = position.width / 2+40;
              rect2.y = rect1.y;
      
              EditorGUI.PropertyField(rect1, spName, new GUIContent("名字"));
              EditorGUI.PropertyField(rect2, spAge, new GUIContent("年齡"));
      
              EditorGUI.indentLevel = indentlevel;
              EditorGUIUtility.labelWidth = lableWidth;
      
              //EditorGUI.DrawRect(rect1, Color.green);
              //EditorGUI.DrawRect(rect2, Color.gray);
          }
      
          //獲取屬性高度
          public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
          {
              return base.GetPropertyHeight(property, label);
          }
      }

      修改后顯示效果如下

       

      TestList修改為指定名稱(chēng);Element修改為指定名稱(chēng)

      using UnityEngine;
      using UnityEditor;
      using UnityEditorInternal;
      [CustomEditor(typeof(TestSO))]
      public class TestSOEditor : Editor
      {
          SerializedProperty sPTestList;
          ReorderableList arrayList;
      
          private void OnEnable()
          {
              sPTestList = serializedObject.FindProperty("testList");
      
              if (arrayList == null)
              {
                  arrayList = new ReorderableList(serializedObject, sPTestList, true, true, true, true);    
                  //繪制Header
                  arrayList.drawHeaderCallback += DrawHeader;
                  //繪制數(shù)組元素
                  arrayList.drawElementCallback += DrawElement;
                  //獲取數(shù)組的高度
                  arrayList.elementHeightCallback += DrawElementHeight;
              }
          }
      
          void DrawHeader(Rect rect)
          {
              EditorGUI.LabelField(rect, "測(cè)試列表");
          }
      
          void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
          {
              var element = sPTestList.GetArrayElementAtIndex(index);
              var arrowRect = rect;
      
              int indentLevel = EditorGUI.indentLevel;
              EditorGUI.indentLevel = 1;
              arrowRect.height = EditorGUIUtility.singleLineHeight;
              element.isExpanded = EditorGUI.Foldout(arrowRect, element.isExpanded, new GUIContent("元素" + index));
              EditorGUI.indentLevel = indentLevel;
      
              //EditorGUI.DrawRect(rect, Color.red);
              //EditorGUI.DrawRect(arrowRect, Color.blue);
      
              if (element.isExpanded)
              {
                  rect.y += arrowRect.height;
                  EditorGUI.PropertyField(rect, element);
              }
          }
      
          float DrawElementHeight(int index)
          {
              var element = sPTestList.GetArrayElementAtIndex(index);
              var height = EditorGUIUtility.singleLineHeight;//折疊箭頭的高度   
              if (element.isExpanded)//如果元素展開(kāi) 獲取展開(kāi)內(nèi)容的高度和箭頭的高度之和
                  height += EditorGUI.GetPropertyHeight(element);
              return height;
          }
      
          public override void OnInspectorGUI()
          {
              serializedObject.Update();
              arrayList.DoLayoutList();
              serializedObject.ApplyModifiedProperties();
          }
      }

      修改后如下圖所示

       

      以上內(nèi)容轉(zhuǎn)自https://blog.csdn.net/weixin_43796392/article/details/143320943

      posted on 2025-04-29 11:48  凌落成迷  閱讀(142)  評(píng)論(0)    收藏  舉報(bào)

      主站蜘蛛池模板: 亚洲精品一区二区三天美| 动漫AV纯肉无码AV电影网| 午夜视频免费试看| 欧美国产日韩在线三区| 精品无码一区二区三区水蜜桃| 免费国产拍久久受拍久久| 日本成人午夜一区二区三区| 久久久精品人妻一区二区三区| 日日爽日日操| 亚洲精中文字幕二区三区| 国产精品成人av电影不卡| 高级艳妇交换俱乐部小说| 国产精品视频一品二区三| 亚洲国产精品综合久久20| 亚洲一区二区色情苍井空| 人妻精品中文字幕av| 国产成人av免费观看| 中文字幕乱偷无码av先锋蜜桃| 日本区二区三区不卡视频| 91青青草视频在线观看| 国产嫩草精品网亚洲av| 一本精品99久久精品77| 少妇人妻精品一区二区| 免费看亚洲一区二区三区| 最新亚洲人成网站在线影院 | 日本欧美大码a在线观看| 自偷自拍亚洲综合精品| 亚洲一二三区精品美妇| 人妻中文字幕一区二区视频| 国产在线观看免费观看不卡| 久久99精品久久久久麻豆| 精品亚洲精品日韩精品| 国产精品看高国产精品不卡| 日韩熟女乱综合一区二区| 高清无码爆乳潮喷在线观看| 梅河口市| 最新午夜男女福利片视频 | 四虎成人精品无码| av激情亚洲男人的天堂| 亚洲综合一区国产精品| 白水县|