Exemple #1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            var properties = serializedObject.FindProperty("m_Data");

            var type = properties.FindPropertyRelative("m_Type");

            GUILayout.Space(3f);
            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);
            EditorGUILayout.LabelField("Type: " + (!type.hasMultipleDifferentValues ? type.enumNames[type.enumValueIndex] : "—"), EditorStyles.boldLabel);
            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);

            var visible = properties.FindPropertyRelative("m_IsVisible");

            GUILayout.Space(2f);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(visible, new GUIContent("Visible: "));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                reloadClips();
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);

            var offset = properties.FindPropertyRelative("m_Offset");

            GUILayout.Space(3f);
            EditorGUI.BeginChangeCheck();
            drawVector3Property(offset, "Position offset: ");
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                foreach (var _target in targets)
                {
                    _target.transform.localPosition = _target.serializedProperties.statePosition + offset.vector3Value + (Vector3)_target.serializedProperties.clip.settings.pivotOffset;
                }
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);

            var meshSizeMultiplier = properties.FindPropertyRelative("m_MeshSizeMultiplier");

            GUILayout.Space(3f);
            EditorGUI.BeginChangeCheck();
            drawVector2Property(meshSizeMultiplier, "Mesh scale: ");
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                reloadClips();
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);

            var material = properties.FindPropertyRelative("m_Material");

            GUILayout.Space(3f);
            EditorGUILayout.LabelField("* Custom material will break dynamic batching!");
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(material, new GUIContent("Custom material: "));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                reloadClips();
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);

            GUILayout.Space(3f);
            var useCustomTextureRectProperty = properties.FindPropertyRelative("m_UseCustomTextureRect");

            if (!useCustomTextureRectProperty.hasMultipleDifferentValues)
            {
                var useCustomTextureRect = EditorGUILayout.Foldout(useCustomTextureRectProperty.boolValue, "Custom texture rect:");
                if (useCustomTextureRect != useCustomTextureRectProperty.boolValue)
                {
                    foreach (var _target in targets)
                    {
                        _target.serializedProperties.useCustomTextureRect = useCustomTextureRect;
                    }

                    if (!useCustomTextureRect)
                    {
                        reloadClips();
                    }
                }

                if (useCustomTextureRect)
                {
                    var atlasTextureRectProperty = properties.FindPropertyRelative("m_AtlasTextureRect");
                    EditorGUI.BeginChangeCheck();
                    drawRectProperty(atlasTextureRectProperty, "Atlas texture Rect: ");
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                        reloadClips();
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Cannot edit custom texture rect for multiple targets.", MessageType.Info);
            }
        }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(2f);

            var enabled = target.objects != null && target.objects.Count() > 0 && target.objects.All(obj => !System.Object.Equals(obj, null));

            if (!enabled)
            {
                EditorGUILayout.LabelField("It's no baked objects in movie clip", EditorStyles.boldLabel);
            }
            else
            {
                if (m_WithoutController == null)
                {
                    m_WithoutController = target.objects.Where((obj) => !target.hasController(obj.serializedProperties.objectID)).Select(obj => obj.serializedProperties.objectID).ToList();
                    m_WithContoller     = target.objects.Where((obj) => target.hasController(obj.serializedProperties.objectID)).Select(obj => obj.serializedProperties.objectID).ToList();
                }

                var bakeIntoSingleMeshContent = new GUIContent("Bake into a sigle mesh", "Ability to bake all animation parts into a single mesh.​");
                GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);

                var oldMode = !EditorGUILayout.Toggle(bakeIntoSingleMeshContent, !target.oldMode);
                GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);
                GUILayout.Space(4f);

                if (oldMode)
                {
                    GUI.enabled   = false;
                    m_ShowObjects = true;
                }

                if (target.oldMode != oldMode)
                {
                    if (oldMode)
                    {
                        target.regroupInOldMode();
                        target.movieClip.reload();
                    }
                    else
                    {
                        target.regroupInNewMode();
                        target.movieClip.reload();
                    }

                    refillControllersLists();
                }

                m_ShowObjects = EditorGUILayout.Foldout(m_ShowObjects, "Objects: ");

                if (m_ShowObjects)
                {
                    EditorGUILayout.BeginVertical();
                    {
                        var horizontalScrollbar = new GUIStyle(GUI.skin.horizontalScrollbar);
                        var verticalScrollbar   = new GUIStyle(GUI.skin.verticalScrollbar);
                        var area = new GUIStyle(GUI.skin.textArea);

                        m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition, false, false, horizontalScrollbar, verticalScrollbar, area, GUILayout.Height(200f));
                        {
                            var selectedAllValue = target.objectsDict.Count == m_WithoutController.Count;
                            var actualState      = selectedAllValue;

                            actualState = EditorGUILayout.ToggleLeft("\tAll", selectedAllValue, EditorStyles.boldLabel);

                            GUILayout.Space(5f);

                            if (selectedAllValue != actualState)
                            {
                                if (actualState)
                                {
                                    m_WithoutController = m_WithoutController.Union(m_WithContoller).ToList();
                                    m_WithContoller.Clear();
                                }
                                else if (selectedAllValue)
                                {
                                    m_WithContoller = m_WithContoller.Union(m_WithoutController).ToList();
                                    m_WithoutController.Clear();
                                }
                            }
                            foreach (var obj in target.objectsDict.Values)
                            {
                                EditorGUILayout.BeginHorizontal();
                                {
                                    var currentEnabled = m_WithoutController.Contains(obj.serializedProperties.objectID);
                                    var nextEnabled    = EditorGUILayout.ToggleLeft("\t" + obj.serializedProperties.name, currentEnabled, GUILayout.MaxWidth(150f));
                                    EditorGUILayout.LabelField("Type: " + obj.serializedProperties.type.ToString(), GUILayout.Width(90f));

                                    if (nextEnabled != currentEnabled)
                                    {
                                        if (nextEnabled)
                                        {
                                            m_WithoutController.Add(obj.serializedProperties.objectID);
                                            m_WithContoller.Remove(obj.serializedProperties.objectID);
                                        }
                                        else
                                        {
                                            m_WithContoller.Add(obj.serializedProperties.objectID);
                                            m_WithoutController.Remove(obj.serializedProperties.objectID);
                                        }
                                    }
                                }
                                EditorGUILayout.EndHorizontal();
                                GUILayout.Space(1f);
                            }
                        }
                        EditorGUILayout.EndScrollView();

                        GUILayout.Space(5f);

                        var actualWithout = getObjectsWithoutController();
                        var actualWith    = getObjectsWithController();

                        GUI.enabled = actualWithout.ConvertAll(value => (int)value).Sum() != m_WithoutController.ConvertAll(value => (int)value).Sum();

                        EditorGUILayout.BeginHorizontal();
                        {
                            if (GUILayout.Button("Commit"))
                            {
                                var toRemove = m_WithoutController.Except(actualWithout).ToList();
                                var toAdd    = m_WithContoller.Except(actualWith).ToList();

                                for (int i = 0; i < toAdd.Count; i++)
                                {
                                    target.addControllerToObject(toAdd[i]);
                                }
                                for (int i = 0; i < toRemove.Count; i++)
                                {
                                    target.removeControllerFromObject(toRemove[i]);
                                }

                                target.movieClip.reload();

                                refillControllersLists();
                            }

                            if (GUILayout.Button("Cancel"))
                            {
                                refillControllersLists();
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.EndVertical();
                }

                GUILayout.Space(5f);
            }
        }
Exemple #3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(3f);
            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);
            EditorGUILayout.LabelField("Type: " + target.bakedObject.serializedProperties.type.ToString());
            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);

            GUILayout.Space(3f);
            var offset = EditorGUILayout.Vector3Field("Position offset: ", target.bakedObject.serializedProperties.offset);

            if (offset != target.bakedObject.serializedProperties.offset)
            {
                target.bakedObject.serializedProperties.offset = offset;
                target.transform.localPosition = target.bakedObject.serializedProperties.offset;
                target.bakedObject.serializedProperties.clip.reload();
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);
            GUILayout.Space(2f);
            var visible = EditorGUILayout.Toggle("Visible: ", target.bakedObject.serializedProperties.visible);

            if (visible != target.bakedObject.serializedProperties.visible)
            {
                target.bakedObject.serializedProperties.visible = visible;
                target.bakedObject.serializedProperties.clip.reload();
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);
            GUILayout.Space(3f);
            EditorGUI.BeginChangeCheck();
            {
                target.bakedObject.serializedProperties.meshSizeMultiplier = EditorGUILayout.Vector2Field("Mesh scale: ", target.bakedObject.serializedProperties.meshSizeMultiplier);

                if (EditorGUI.EndChangeCheck())
                {
                    target.bakedObject.serializedProperties.clip.reload();
                }
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);
            GUILayout.Space(3f);
            EditorGUILayout.LabelField("* Custom material will break dynamic batching!");
            var material = EditorGUILayout.ObjectField("Custom material: ", target.bakedObject.serializedProperties.material, typeof(Material), false) as Material;

            if (material != target.bakedObject.serializedProperties.material)
            {
                target.bakedObject.serializedProperties.material = material;
                target.bakedObject.serializedProperties.clip.reload();
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);
            GUILayout.Space(3f);
            var useCustomTextureRect = EditorGUILayout.Foldout(target.bakedObject.serializedProperties.useCustomTextureRect, "Custom texture rect:");

            if (useCustomTextureRect != target.bakedObject.serializedProperties.useCustomTextureRect)
            {
                target.bakedObject.serializedProperties.useCustomTextureRect = useCustomTextureRect;
                if (!useCustomTextureRect)
                {
                    target.bakedObject.serializedProperties.clip.reload();
                }
            }

            if (useCustomTextureRect)
            {
                EditorGUI.BeginChangeCheck();
                {
                    target.bakedObject.serializedProperties.atlasTextureRect = EditorGUILayout.RectField(target.bakedObject.serializedProperties.atlasTextureRect);

                    if (EditorGUI.EndChangeCheck())
                    {
                        target.bakedObject.serializedProperties.clip.reload();
                    }
                }
            }

            GAFInspectorLine.draw(new Color(125f / 255f, 125f / 255f, 125f / 255f), 1f);
            GUILayout.Space(5f);
            if (GUILayout.Button(new GUIContent("Copy mesh")))
            {
                target.copyMesh();
            }
        }