Пример #1
0
    //generate a new hierarchy data with a root heirarchy and object heirarchy
    void newHierarchy()
    {
        if (gameObjectHierarchy)
        {
            GameObject rootObject;
            rootObject = EditorGUILayout.ObjectField("Root", null, typeof(GameObject), true) as GameObject;
            if (rootObject)
            {
                //remove old poses and start updating heirarchy
                animData.deletePoses();
                gameObjectHierarchy.newList();
                createNewHierarchy = false;

                int rootIndex = gameObjectHierarchy.addObjectWithIndex(rootObject, -1);
                animData.addNewPose(rootObject, rootObject, -1);
                checkChildren(rootObject, rootIndex);

                frameDuration = animData.totalFrameDuration;

                //update all old frames and update new ones
                animData.prioFrameKey = new bool[animData.totalFrameDuration];
                for (int i = 0; i < animData.totalFrameDuration; i++)
                {
                    animData.prioFrameKey[i] = false;

                    //reason to go throught each pose is because we want to fill the frames with dummy data
                    for (int j = 0; j < animData.poseBase.Length; j++)
                    {
                        copyDownDataAndAdd(j);
                    }
                }
                //the last and first keys are primary keys by default and always will be
                animData.prioFrameKey[0] = true;
                animData.prioFrameKey[animData.totalFrameDuration - 1] = true;

                updatePrioKeySet = animData.prioFrameKey;
            }
        }
        else
        {
            GUILayout.Label("Need GameObjectHierarchy");
        }
    }