private void OnEnable()
        {
            InteractionRigSetup rigSetup = (InteractionRigSetup)target;

            if (Application.isPlaying == false)
            {
                foundProvider = rigSetup.UpdateRigList();
            }

            list = new ReorderableList(serializedObject,
                                       serializedObject.FindProperty("PossibleInteractionRigs"),
                                       true, true, false, false);

            list.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Available Interaction Rigs"); };

            list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                if (foundProvider == null || foundProvider.Count == 0 || foundProvider.Count <= index)
                {
                    foundProvider = rigSetup.UpdateRigList();
                }

                InteractionRigProvider provider = FindProvider(rigSetup.PossibleInteractionRigs[index].Name);

                Rect labelRect = new Rect(rect.x, rect.y, rect.width - 2 * lineHeight - 4, lineHeight);
                if (provider != null)
                {
                    bool canBeUsed = provider.CanBeUsed();
                    GUI.enabled = canBeUsed;
                    EditorGUI.LabelField(labelRect, provider.Name);
                    GUI.enabled = true;

                    Rect toggleRect = new Rect(rect.x + rect.width - 2 * lineHeight, rect.y, lineHeight, lineHeight);
                    rigSetup.PossibleInteractionRigs[index].Enabled = EditorGUI.Toggle(toggleRect, rigSetup.PossibleInteractionRigs[index].Enabled);

                    if (canBeUsed == false)
                    {
                        Rect       warningRect  = new Rect(rect.x + rect.width - lineHeight, rect.y, lineHeight, lineHeight);
                        GUIContent labelContent = new GUIContent("", warningIcon.image, provider.GetSetupTooltip());
                        EditorGUI.LabelField(warningRect, labelContent);
                    }
                }
                else
                {
                    EditorGUI.LabelField(labelRect, "#Error");
                    foundProvider = rigSetup.UpdateRigList();
                    Repaint();
                }
            };

            list.onReorderCallback = reorderableList =>
            {
                foundProvider = rigSetup.UpdateRigList();
            };

            list.drawFooterCallback = rect => { };
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public override void Setup()
        {
            RemoveMainCamera();

            InteractionRigSetup setup = Object.FindObjectOfType <InteractionRigSetup>();

            if (setup == null)
            {
                SetupPrefab("[INTERACTION_RIG_LOADER]");
                setup = Object.FindObjectOfType <InteractionRigSetup>();
                setup.UpdateRigList();
            }

            TraineeSceneObject trainee = Object.FindObjectOfType <TraineeSceneObject>();

            if (trainee == null)
            {
                SetupPrefab("[TRAINEE]");
                setup.DummyTrainee = GameObject.Find("[TRAINEE]");
            }
        }