Exemple #1
0
 public static void initialize()
 {
     if (Instance == null)
     {
         Instance = CreateInstance(typeof(AnimationsWatcher)) as AnimationsWatcher;
     }
 }
Exemple #2
0
 void initializeAnimationsWatcher()
 {
     AnimationsWatcher.initialize();
     if (m_lastConfig == null)
     {
         m_lastConfig = AnimationsWatcher.configParams.Copy();
     }
     else
     {
         AnimationsWatcher.Instance.m_configParams = m_lastConfig.Copy();
     }
     initSerializationParams();
 }
Exemple #3
0
    void OnGUI()
    {
        if (AnimationsWatcher.Instance == null)
        {
            initializeAnimationsWatcher();
        }
        m_serializationParams.instance.Update();
        // Paint configurations
        AnimationsWatcher.configParams.showConfig = EditorGUILayout.Foldout(AnimationsWatcher.configParams.showConfig, "Configuration");
        if (AnimationsWatcher.configParams.showConfig == true)
        {
            ConfigGUI();
        }
        MoreOptionsGUI();

        m_serializationParams.instance.ApplyModifiedProperties();

        m_lastConfig = AnimationsWatcher.configParams.Copy();

        // Determine which game objects to show
        List <GameObject> targetGameObjects = new List <GameObject>();

        if (AnimationsWatcher.configParams.useHierarchySelection == true)
        {
            // Traverse the inspector selected objects
            foreach (Object obj in Selection.objects)
            {
                if (obj.GetType() == typeof(GameObject))
                {
                    targetGameObjects.Add((GameObject)obj);
                }
            }
        }
        if (AnimationsWatcher.configParams.useSpecificGameObject == true)
        {
            // Just use the single specified user game object
            targetGameObjects.Add(AnimationsWatcher.configParams.specificGameObject);
        }

        // If no object selected or user didn't specify any object then finish quietly
        if (targetGameObjects.Count == 0)
        {
            return;
        }

        // Prepare a list with all game objects which have an animation component
        List <GameObject> allGameObjects = new List <GameObject>();

        foreach (GameObject gameObject in targetGameObjects)
        {
            allGameObjects.AddRange(AnimationsWatcher.GetGameObjectsWithAnimation(gameObject, AnimationsWatcher.configParams.showChildren));
        }
        if (allGameObjects.Count == 0)
        {
            GUILayout.Label("Selected game object(s)", EditorStyles.boldLabel);
            GUILayout.Label("doesn't have animation component", EditorStyles.boldLabel);
        }

        // And now traverse the all apropriate game objects and paint their GUI
        EditorGUILayout.Separator();
        AnimationsWatcher.configParams.scrollPos = EditorGUILayout.BeginScrollView(AnimationsWatcher.configParams.scrollPos);
        foreach (GameObject currentObject in allGameObjects)
        {
            GUILayout.Label(currentObject.name, EditorStyles.boldLabel);
            IComparer <AnimationState> comparer = new AnimationsWatcher.LayerSort();
            switch (AnimationsWatcher.configParams.sortingMethod)
            {
            case 0:
                comparer = new AnimationsWatcher.LayerSort();
                break;

            case 1:
                comparer = new AnimationsWatcher.NameSort();
                break;

            case 2:
                comparer = new AnimationsWatcher.WeightSort();
                break;
            }
            List <AnimationState> objectAnimStates = AnimationsWatcher.GetAnimationsSorted(currentObject.GetComponent <Animation>(), comparer, AnimationsWatcher.configParams.showAnimationsNotPlaying);
            foreach (AnimationState animState in objectAnimStates)
            {
                AnimationStateGUI(animState, currentObject.GetComponent <Animation>());
            }
        }
        EditorGUILayout.EndScrollView();
    }