示例#1
0
 static public int GetLabelWidth <T>(this string pStr, BaseDrawer <T> pDrawer)
 {
     if (pDrawer != null)
     {
         var tType          = pDrawer.GetType();
         var tCustomArrList = tType.GetCustomAttributes(typeof(MemeberDrawerAttribute), false);
         if (tCustomArrList != null && tCustomArrList.Length == 1)
         {
             var tDrawerAtt = (MemeberDrawerAttribute)tCustomArrList[0];
             switch (tDrawerAtt.memberType)
             {
             case MemberTypes.Method:
                 return(pStr.IsNullOrEmpty() ? 0 : (pStr.Length * 7 + 5));
             }
         }
     }
     return(pStr.IsNullOrEmpty() ? 0 : pStr.Length * 7);
 }
示例#2
0
        static public Vector3 Vector3Field <T>(Vector3 pVal, BaseDrawer <T> pDrawer, string pName = "")
        {
            EditorGUILayout.BeginHorizontal();
            if (!pName.IsNullOrEmpty())
            {
                EditorGUILayout.LabelField(pName, GUILayout.Width(pName.GetLabelWidth(pDrawer)));
                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }
            EditorGUILayout.LabelField("X", GUILayout.Width(15));
            pVal.x = EditorGUILayout.FloatField(pVal.x);
            EditorGUILayout.LabelField("Y", GUILayout.Width(15));
            pVal.y = EditorGUILayout.FloatField(pVal.y);
            EditorGUILayout.LabelField("Z", GUILayout.Width(15));
            pVal.z = EditorGUILayout.FloatField(pVal.z);
            EditorGUILayout.EndHorizontal();

            return(pVal);
        }