Exemple #1
0
        public static VisualElement CreateHolder(AnimatorLayerDefinition def, AvatarParameterData data)
        {
            def.TryGetFirstParent(out AnimatorDefinition animDef);
            var fields = CreateHolder(() => animDef.Animator.SelectAnimatorLayer(def.Layer), $"{animDef.Name}/{def.Layer.name}", def);

            fields.SetupDeletion(fields.DeleteButton, fields.ObjectField, def, data);
            return(fields.Container);
        }
Exemple #2
0
        public static VisualElement CreateHolder(MenuControlDefinition def, AvatarParameterData data)
        {
            def.TryGetFirstParent(out MenuDefinition menu);
            var name   = $"{menu.Menu.name}/{def.Name}";
            var fields = CreateHolder(() => Selection.activeObject = menu.Menu, name, def);

            fields.SetupDeletion(fields.DeleteButton, fields.ObjectField, def, data);
            return(fields.Container);
        }
Exemple #3
0
        public static VisualElement CreateHolder(VrcParameterDefinition def, AvatarParameterData data)
        {
            def.TryGetFirstParent(out AvatarDefinition avatar);
            var fields = CreateHolder(() => Selection.activeObject = avatar.VrcExpressionParameters, $"{def.Name} ({def.Type})", def);

            fields.SetupDeletion(fields.DeleteButton, fields.ObjectField, def, data);

            return(fields.Container);
        }
Exemple #4
0
        public static VisualElement CreateHolder(VrcParameterDriverDefinition def, AvatarParameterData data)
        {
            void Action()
            {
                var layer    = def.GetParents <AnimatorLayerDefinition>().FirstOrDefault();
                var animator = def.GetParents <AnimatorDefinition>().FirstOrDefault();

                if ((layer?.IsRealized ?? false) && (animator?.IsRealized ?? false) && def.Parent is StateDefinition state)
                {
                    animator.Animator.SelectAnimatorLayer(layer.Layer);
                    EditorApplication.delayCall += () => Selection.activeObject = state.State;
                }
            }

            var fields = CreateHolder(Action, $"{def}", def);

            fields.SetupDeletion(fields.DeleteButton, fields.ObjectField, def, data);
            return(fields.Container);
        }
Exemple #5
0
        private void SetupDeletion(Button deleteButton, ObjectField field, IAnimationDefinition def, AvatarParameterData data)
        {
            string deleteText   = "x";
            string undeleteText = "+";

            deleteButton.text = deleteText;
            void DeleteClicked()
            {
                var noDelete = !data.MarkForDeletion(this);

                field.SetEnabled(noDelete);
                deleteButton.AddToClassList("button--danger--green");
                deleteButton.text = undeleteText;
                if (noDelete)
                {
                    deleteButton.text = deleteText;
                    deleteButton.RemoveFromClassList("button--danger--green");
                    data.UnMarkForDeletion(def);
                }
            }

            deleteButton.clicked += DeleteClicked;
        }