コード例 #1
0
        public override void DrawFields(FieldInfo fieldInfo)
        {
            if (fieldInfo.Name == "anim")
            {
                GUIContent lable     = new GUIContent(fieldInfo.Name);
                float      tmpHeight = GUIExtension.GetHeight(fieldInfo.FieldType, lable);

                UnityObjectAsset oldObj       = (UnityObjectAsset)fieldInfo.GetValue(Target);
                ObjectDrawer     objectDrawer = ObjectDrawer.CreateEditor(oldObj);
                objectDrawer.OnGUI(EditorGUILayout.GetControlRect(true, tmpHeight), lable);
                if (GUILayout.Button("设置为动画时长"))
                {
                    AnimationClip clip = (AnimationClip)oldObj.GetObj();
                    if (clip != null)
                    {
                        ClipModel clipModel = Target as ClipModel;
                        clipModel.SetEnd(clipModel.StartTime + clip.length);
                    }
                }
            }
            else
            {
                base.DrawFields(fieldInfo);
            }
        }
コード例 #2
0
 private void GetAsset(UnityObjectAsset unityObject)
 {
     if (unityObject == null || string.IsNullOrEmpty(unityObject.ObjPath))
     {
         return;
     }
     unityObject.Obj = unityObject.GetObj();
 }
コード例 #3
0
 private void UpdateAssetPath(UnityObjectAsset unityObject)
 {
     if (unityObject == null || unityObject.Obj == null)
     {
         unityObject.ObjPath = "";
         return;
     }
     unityObject.ObjPath = AssetDatabase.GetAssetPath(unityObject.Obj);
     unityObject.ObjName = unityObject.Obj.name;
 }
コード例 #4
0
        public override object OnGUI(Rect _position, GUIContent _label)
        {
            if (Target == null)
            {
                Target = new UnityObjectAsset();
            }

            UnityObjectAsset unityObject = Target as UnityObjectAsset;
            Type             objType     = unityObject.GetObjType();

            GetAsset(unityObject);
            UnityObject tmpObj = unityObject.Obj;

            tmpObj = EditorGUI.ObjectField(_position, _label, tmpObj, objType, false);
            if (tmpObj != null && !tmpObj.Equals(unityObject.Obj))
            {
                unityObject.Obj = tmpObj;
                UpdateAssetPath(unityObject);
            }

            return(Target);
        }