Пример #1
0
        public static void DrawCapturingProgress(int editorWidth, int editorHeight, List <Model> bakingModels, Sampler sampler, Batcher batcher)
        {
            EditorGUILayout.HelpBox("Don't do anything while capturing..", MessageType.Warning);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            GUIStyle titleStyle = new GUIStyle();

            titleStyle.alignment        = TextAnchor.UpperCenter;
            titleStyle.fontSize         = 16;
            titleStyle.fontStyle        = FontStyle.Bold;
            titleStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black;

            if (sampler != null)
            {
                EditorGUILayout.LabelField("Sampling..", titleStyle);
                EditorGUILayout.Space();
                EditorGUILayout.Space();
            }
            else if (batcher != null)
            {
                DrawBakingProgress(editorWidth, editorHeight, titleStyle, bakingModels, batcher);
            }

            EditorGUILayout.Space();
            if (DrawingHelper.DrawMiddleButton("Cancel"))
            {
                if (sampler != null)
                {
                    sampler.IsCancelled = true;
                    sampler.Finish();
                }
                else if (batcher != null)
                {
                    Baker baker = batcher.CurrentBaker;
                    if (baker != null)
                    {
                        baker.IsCancelled = true;
                        baker.Finish();
                    }
                    batcher.Finish();
                }
            }
            EditorGUILayout.Space();
        }
Пример #2
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);
            }
        }