示例#1
0
        protected void OnInspectorGUI_Multi()
        {
            EditorGUILayout.HelpBox("Displayed information is of the first selected model,\nbut any change affects all selected models.", MessageType.Info);

            MeshModel[] models = new MeshModel[targets.Length];

            for (int i = 0; i < models.Length; ++i)
            {
                models[i] = targets[i] as MeshModel;
            }

            MeshModel firstModel = models[0];

            bool isAllSkinnedModel = true;

            foreach (MeshModel model in models)
            {
                isAllSkinnedModel &= model.IsSkinnedModel();
            }

            bool isAllNotFixingToGround = true;

            foreach (MeshModel model in models)
            {
                isAllNotFixingToGround &= (!model.isFixingToOrigin || !model.isFixingToGround);
            }

            PivotType pivotType            = PivotType.Bottom;
            bool      isPivotTypeChanged   = false;
            bool      isGroundPivot        = false;
            bool      isGroundPivotChanged = false;

            if (isAllSkinnedModel || isAllNotFixingToGround)
            {
                EditorGUILayout.Space();

                if (isAllSkinnedModel)
                {
                    pivotType = DrawPivotTypeField(firstModel, out isPivotTypeChanged);
                }

                if (isAllNotFixingToGround)
                {
                    isGroundPivot = DrawGroundPivotField(firstModel, out isGroundPivotChanged);
                }
            }

            bool hasAllRootBone = true;

            foreach (MeshModel model in models)
            {
                hasAllRootBone &= (model.rootBoneObj != null);
            }

            bool isFixingToOrigin        = false;
            bool isFixingToOriginChanged = false;

            bool isAllFixingToOrigin     = true;
            bool isAllNotGroundPivot     = true;
            bool isFixingToGround        = false;
            bool isFixingToGroundChanged = false;

            if (isAllSkinnedModel && hasAllRootBone)
            {
                EditorGUILayout.Space();

                EditorGUILayout.LabelField("Root Bone");

                EditorGUI.indentLevel++;
                {
                    isFixingToOrigin = DrawFixToOriginField(firstModel, out isFixingToOriginChanged);

                    foreach (MeshModel model in models)
                    {
                        isAllFixingToOrigin &= model.isFixingToOrigin;
                    }
                    foreach (MeshModel model in models)
                    {
                        isAllNotGroundPivot &= !model.isGroundPivot;
                    }

                    if (isAllFixingToOrigin && isAllNotGroundPivot)
                    {
                        EditorGUI.indentLevel++;
                        isFixingToGround = DrawFixToGroundField(firstModel, out isFixingToGroundChanged);
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            bool       isSpritePrefabChanged;
            GameObject spritePrefab = DrawSpritePrefabField(firstModel, out isSpritePrefabChanged);

            bool hasAllSpritePrefab = true;

            foreach (MeshModel model in models)
            {
                hasAllSpritePrefab &= (model.spritePrefab != null);
            }

            PrefabBuilder prefabBuilder          = null;
            bool          isPrefabBuilderChanged = false;

            if (hasAllSpritePrefab)
            {
                EditorGUI.indentLevel++;
                prefabBuilder = DrawPrefabBuilderField(model, out isPrefabBuilderChanged);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            bool   isNameSuffixChanged;
            string nameSuffix = DrawModelNameSuffix(firstModel, out isNameSuffixChanged);

            if (isNameSuffixChanged)
            {
                PathHelper.CorrectPathString(ref nameSuffix);
            }

            if (isPivotTypeChanged || isGroundPivotChanged || isFixingToOriginChanged || isFixingToGroundChanged ||
                isSpritePrefabChanged || isPrefabBuilderChanged || isNameSuffixChanged)
            {
                foreach (MeshModel model in models)
                {
                    Undo.RecordObject(model, "Mesh Model");

                    if (isAllSkinnedModel && isPivotTypeChanged)
                    {
                        model.pivotType = pivotType;
                    }
                    if (isAllNotFixingToGround && isGroundPivotChanged)
                    {
                        model.isGroundPivot = isGroundPivot;
                    }

                    if (isAllSkinnedModel && hasAllRootBone)
                    {
                        if (isFixingToOriginChanged)
                        {
                            model.isFixingToOrigin = isFixingToOrigin;
                        }
                        if (isAllFixingToOrigin && isAllNotGroundPivot && isFixingToGroundChanged)
                        {
                            model.isFixingToGround = isFixingToGround;
                        }
                    }

                    if (isSpritePrefabChanged)
                    {
                        model.spritePrefab = spritePrefab;
                    }

                    if (hasAllSpritePrefab && isPrefabBuilderChanged)
                    {
                        model.prefabBuilder = prefabBuilder;
                    }

                    if (isNameSuffixChanged)
                    {
                        model.nameSuffix = nameSuffix;
                    }
                }
            }

            Studio studio = FindObjectOfType <Studio>();

            if (studio == null)
            {
                return;
            }

            EditorGUILayout.Space();

            if (DrawingHelper.DrawWideButton("Add all to the model list"))
            {
                foreach (MeshModel model in models)
                {
                    AddToModelList(model);
                }
            }
        }
示例#2
0
        private void OnInspectorGUI_Single()
        {
            Undo.RecordObject(model, "Particle Model");

            bool isAnyChanged = false;

            EditorGUI.BeginChangeCheck();
            model.mainParticleSystem = EditorGUILayout.ObjectField("Main Particle System",
                                                                   model.mainParticleSystem, typeof(ParticleSystem), true) as ParticleSystem;
            if (EditorGUI.EndChangeCheck())
            {
                model.targetChecked = false;
            }

            if (model.mainParticleSystem == null)
            {
                model.TrySetMainParticleSystem();
            }

            if (model.mainParticleSystem != null)
            {
                if (!model.targetChecked)
                {
                    model.CheckModel();
                }

                if (model.animationClip != null)
                {
                    EditorGUI.indentLevel++;
                    GUI.enabled = false;
                    EditorGUILayout.FloatField("Duration", model.mainParticleSystem.main.duration, EditorStyles.label);
                    GUI.enabled = true;
                    EditorGUI.indentLevel--;
                }
            }

            EditorGUILayout.Space();

            model.isGroundPivot = DrawGroundPivotField(model, out isAnyChanged);

            EditorGUILayout.Space();

            model.isLooping = DrawLoopingField(model, out isAnyChanged);
            if (model.isLooping)
            {
                EditorGUI.indentLevel++;
                model.isPrewarm = DrawPrewarmField(model, out isAnyChanged);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            model.spritePrefab = DrawSpritePrefabField(model, out isAnyChanged);
            if (model.spritePrefab != null)
            {
                EditorGUI.indentLevel++;
                model.prefabBuilder = DrawPrefabBuilderField(model, out isAnyChanged);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            bool isNameSuffixChanged;

            model.nameSuffix = DrawModelNameSuffix(model, out isNameSuffixChanged);
            if (isNameSuffixChanged)
            {
                PathHelper.CorrectPathString(ref model.nameSuffix);
            }

            EditorGUILayout.Space();

            if (DrawingHelper.DrawWideButton("Add to the model list"))
            {
                AddToModelList(model);
            }
        }
示例#3
0
        private void OnInspectorGUI_Single()
        {
            Undo.RecordObject(model, "Mesh Model");

            bool isAnyChanged = false;

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            model.mainRenderer = EditorGUILayout.ObjectField(new GUIContent("Main Renderer",
                                                                            "the most important and biggest renderer in hierarchy"), model.mainRenderer, typeof(Renderer), true) as Renderer;
            bool mainRendererChanged = EditorGUI.EndChangeCheck();

            if (model.mainRenderer == null)
            {
                model.mainRenderer = MeshModel.FindBiggestRenderer(model.gameObject);
            }

            if (model.IsSkinnedModel())
            {
                EditorGUILayout.Space();

                if (mainRendererChanged)
                {
                    model.pivotType = PivotType.Bottom;
                }

                bool isPivotTypeChanged;
                model.pivotType = DrawPivotTypeField(model, out isPivotTypeChanged);
                if (isPivotTypeChanged)
                {
                    UpdateSceneWindow();
                }
            }
            else
            {
                model.pivotType = PivotType.Center;
            }

            if (model.isFixingToOrigin && model.isFixingToGround)
            {
                GUI.enabled = false;
            }
            {
                bool isGroundPivotChanged;
                model.isGroundPivot = DrawGroundPivotField(model, out isGroundPivotChanged);
                if (isGroundPivotChanged)
                {
                    UpdateSceneWindow();
                }
            }
            if (model.isFixingToOrigin && model.isFixingToGround)
            {
                GUI.enabled = true;
            }

            if (model.IsSkinnedModel())
            {
                EditorGUILayout.Space();

                EditorGUI.BeginChangeCheck();

                model.rootBoneObj = EditorGUILayout.ObjectField(new GUIContent("Root Bone",
                                                                               "root bone object to fix body"), model.rootBoneObj, typeof(Transform), true) as Transform;

                if (model.rootBoneObj == null)
                {
                    GUI.enabled = false;
                }
                EditorGUI.indentLevel++;
                {
                    model.isFixingToOrigin = DrawFixToOriginField(model, out isAnyChanged);
                    if (model.isFixingToOrigin)
                    {
                        EditorGUI.indentLevel++;
                        if (model.isGroundPivot)
                        {
                            GUI.enabled = false;
                        }
                        model.isFixingToGround = DrawFixToGroundField(model, out isAnyChanged);
                        if (model.isGroundPivot)
                        {
                            GUI.enabled = true;
                        }
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.indentLevel--;
                if (model.rootBoneObj == null)
                {
                    GUI.enabled = true;
                }

                if (EditorGUI.EndChangeCheck())
                {
                    model.Animate(SelectedAnimation, Frame.BEGIN);
                }
            }

            EditorGUILayout.Space();

            if (reservedAnimIndex >= 0)
            {
                SetAnimationByIndex(reservedAnimIndex);
                reservedAnimIndex = -1;
            }

            Rect animBoxRect = EditorGUILayout.BeginVertical();

            serializedObject.Update();
            animReorderableList.DoLayoutList();
            serializedObject.ApplyModifiedProperties();
            EditorGUILayout.EndVertical();

            switch (Event.current.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
            {
                if (!animBoxRect.Contains(Event.current.mousePosition))
                {
                    break;
                }
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                if (Event.current.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();
                    foreach (object draggedObj in DragAndDrop.objectReferences)
                    {
                        AnimationClip clip = draggedObj as AnimationClip;
                        if (clip != null)
                        {
                            MeshAnimation anim = new MeshAnimation();
                            anim.clip           = clip;
                            anim.selectedFrames = new List <Frame>();
                            model.AddAnimation(anim);
                        }
                    }
                }
            }
                Event.current.Use();
                break;
            }

            if (model.animations.Count > 0 && DrawingHelper.DrawMiddleButton("Clear all"))
            {
                model.animations.Clear();
            }

            EditorGUILayout.Space();

            DrawReferenceControllerField();
            if (model.referenceController != null)
            {
                EditorGUI.indentLevel++;
                model.outputController = EditorGUILayout.ObjectField(new GUIContent("Output Controller",
                                                                                    "controller to which a baker saves animation states related to the animation list's animations"),
                                                                     model.outputController, typeof(AnimatorController), false) as AnimatorController;
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            model.spritePrefab = DrawSpritePrefabField(model, out isAnyChanged);
            if (model.spritePrefab != null)
            {
                EditorGUI.indentLevel++;
                model.prefabBuilder = DrawPrefabBuilderField(model, out isAnyChanged);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            if (SelectedAnimation != null)
            {
                SelectedAnimation.customizer = EditorGUILayout.ObjectField(new GUIContent("Customizer",
                                                                                          "component that customizes this model at every frames in the selected animation"),
                                                                           SelectedAnimation.customizer, typeof(AnimationCustomizer), true) as AnimationCustomizer;
            }

            EditorGUILayout.Space();

            bool isNameSuffixChanged;

            model.nameSuffix = DrawModelNameSuffix(model, out isNameSuffixChanged);
            if (isNameSuffixChanged)
            {
                PathHelper.CorrectPathString(ref model.nameSuffix);
            }

            EditorGUILayout.Space();

            if (DrawingHelper.DrawWideButton("Add to the model list"))
            {
                AddToModelList(model);
            }
        }
示例#4
0
        protected void OnInspectorGUI_Multi()
        {
            EditorGUILayout.HelpBox("Displayed information is of the first selected model,\nbut any change affects all selected models.", MessageType.Info);

            ParticleModel[] models = new ParticleModel[targets.Length];

            for (int i = 0; i < models.Length; ++i)
            {
                models[i] = targets[i] as ParticleModel;
            }

            ParticleModel firstModel = models[0];

            EditorGUILayout.Space();

            bool isGroundPivotChanged;
            bool isGroundPivot = DrawGroundPivotField(firstModel, out isGroundPivotChanged);

            EditorGUILayout.Space();

            bool isLoopingChanged;
            bool isLooping = DrawLoopingField(firstModel, out isLoopingChanged);

            bool isAllLooping = true;

            foreach (ParticleModel model in models)
            {
                isAllLooping &= model.isLooping;
            }

            bool isPrewarmChanged = false;
            bool isPrewarm        = false;

            if (isAllLooping)
            {
                EditorGUI.indentLevel++;
                isPrewarm = DrawPrewarmField(firstModel, out isPrewarmChanged);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            bool       isSpritePrefabChanged;
            GameObject spritePrefab = DrawSpritePrefabField(firstModel, out isSpritePrefabChanged);

            bool hasAllSpritePrefab = true;

            foreach (ParticleModel model in models)
            {
                hasAllSpritePrefab &= (model.spritePrefab != null);
            }

            PrefabBuilder prefabBuilder          = null;
            bool          isPrefabBuilderChanged = false;

            if (hasAllSpritePrefab)
            {
                EditorGUI.indentLevel++;
                prefabBuilder = DrawPrefabBuilderField(model, out isPrefabBuilderChanged);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            bool   isNameSuffixChanged;
            string nameSuffix = DrawModelNameSuffix(firstModel, out isNameSuffixChanged);

            if (isNameSuffixChanged)
            {
                PathHelper.CorrectPathString(ref nameSuffix);
            }

            if (isGroundPivotChanged || isLoopingChanged || isPrewarmChanged ||
                isSpritePrefabChanged || isPrefabBuilderChanged || isNameSuffixChanged)
            {
                foreach (ParticleModel model in models)
                {
                    Undo.RecordObject(model, "Particle Model");
                    if (isGroundPivotChanged)
                    {
                        model.isGroundPivot = isGroundPivot;
                    }
                    if (isLoopingChanged)
                    {
                        model.isLooping = isLooping;
                    }
                    if (isPrewarmChanged)
                    {
                        model.isPrewarm = isPrewarm;
                    }
                    if (isSpritePrefabChanged)
                    {
                        model.spritePrefab = spritePrefab;
                    }
                    if (hasAllSpritePrefab && isPrefabBuilderChanged)
                    {
                        model.prefabBuilder = prefabBuilder;
                    }
                    if (isNameSuffixChanged)
                    {
                        model.nameSuffix = nameSuffix;
                    }
                }
            }

            Studio studio = FindObjectOfType <Studio>();

            if (studio == null)
            {
                return;
            }

            EditorGUILayout.Space();

            if (DrawingHelper.DrawWideButton("Add all to the model list"))
            {
                foreach (ParticleModel model in models)
                {
                    AddToModelList(model);
                }
            }
        }