Unity3D/Problems

Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.

일등하이 2013. 9. 3. 09:06
반응형

Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.

UnityEngine.Transform:set_parent(Transform)

SmoothMoves.BuildHelper:UpdateBoneAnimation(BoneAnimation)

SmoothMoves.BuildHelper:UpdateAnimationDataAndPrefabs(BoneAnimationData, Boolean, Int32&, Int32&, Int32&)

SmoothMoves.BuildHelper:UpdateSingleBoneAnimationAndData(BoneAnimation)

TestEditor:OnGUI() (at Assets/Editor/TestEditor.cs:56)

UnityEditor.DockArea:OnGUI()



using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using SmoothMoves;

public class TestEditor : EditorWindow {

    private List<string> list = new List<string>();
    private Vector2 _scrollPos = new Vector2(0, 0);
    private Dictionary<string, object> _dic = new Dictionary<string, object>();
    private bool _foldout = false;

    [MenuItem("Tool/AnimtionChecker")]
    static void Init(){
        EditorWindow window = EditorWindow.GetWindow(typeof(TestEditor));
        window.Show();
    }

    void OnGUI(){

        Debug.Log ("-> " + Event.current);

        EventType type = Event.current.type;


        GUILayout.BeginArea(new Rect(0, 0, position.width, position.height));
        _scrollPos = GUILayout.BeginScrollView(_scrollPos);

        if( type == EventType.Layout){
            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
        }


        if( type == EventType.DragExited ){

            for(int i = 0; i<DragAndDrop.objectReferences.Length; i++){


                list.Add(DragAndDrop.objectReferences[i].name);


                GameObject go = new GameObject ("Bone Animation");


                BoneAnimation boneAnim = go.AddComponent<BoneAnimation>();
                boneAnim.animationData = DragAndDrop.objectReferences[i] as BoneAnimationData;
                Selection.activeGameObject = go;

                _dic.Add(DragAndDrop.objectReferences[i].name,boneAnim);

                BuildHelper.UpdateSingleBoneAnimationAndData(boneAnim);

            }
        }


        if( list.Count > 0 ){
            for( int i = 0; i<list.Count; i++){
                if( _dic.ContainsKey(list[i])){
                    BoneAnimation boneAnimation = (BoneAnimation)_dic[list[i]];
                    EditorGUI.ObjectField(new Rect(0, 20 * i + 20, this.position.width, 20), boneAnimation, typeof(BoneAnimation));
                    Debug.LogWarning(boneAnimation);
                }
            }
        }



        if(GUI.Button(new Rect(0, this.position.y - 40, this.position.width, 20), "Reset")){
            this.list.Clear();
            this._dic.Clear();
        }



        GUILayout.EndScrollView();
        GUILayout.EndArea();


    }
}


반응형