void OnGUI_Spreadsheet_Google()
        {
            GUILayout.Space(20);

#if UNITY_WEBPLAYER
            mConnection_Text = string.Empty;
            EditorGUILayout.HelpBox("Google Synchronization is not supported when in WebPlayer mode." + mConnection_Text, MessageType.Info);

            mProp_GoogleUpdateFrequency.enumValueIndex       = mProp_GoogleUpdateFrequency.enumValueIndex;        // to avoid the warning "unused"
            mProp_GoogleUpdateSynchronization.enumValueIndex = mProp_GoogleUpdateSynchronization.enumValueIndex;
#else
            OnGUI_GoogleCredentials();

            OnGUI_ShowMsg();

            if (string.IsNullOrEmpty(mProp_Google_WebServiceURL.stringValue))
            {
                return;
            }

            if (mWebService_Status == "Offline")
            {
                return;
            }

            GUILayout.Space(20);

            GUI.backgroundColor = Color.Lerp(Color.gray, Color.white, 0.5f);
            GUILayout.BeginVertical(EditorStyles.textArea, GUILayout.Height(1));
            GUI.backgroundColor = Color.white;
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent("  Password", "This should match the value of the LocalizationPassword variable in the WebService Script in your Google Drive"), GUILayout.Width(108));
            mProp_Google_Password.stringValue = EditorGUILayout.TextField(mProp_Google_Password.stringValue, GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();

            OnGUI_GoogleSpreadsheetsInGDrive();
            GUILayout.EndVertical();

            if (mConnection_WWW != null)
            {
                // Connection Status Bar
                int    time    = (int)((Time.realtimeSinceStartup % 2) * 2.5);
                string Loading = mConnection_Text + ".....".Substring(0, time);
                GUI.color = Color.gray;
                GUILayout.BeginHorizontal(EditorStyles.textArea);
                GUILayout.Label(Loading, EditorStyles.miniLabel);
                GUI.color = Color.white;
                if (GUILayout.Button("Cancel", EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)))
                {
                    StopConnectionWWW();
                }
                GUILayout.EndHorizontal();
                Repaint();
            }
            //else
            //	GUILayout.Space(10);


            EditorGUI.BeginChangeCheck();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            LanguageSourceData.eGoogleUpdateFrequency GoogleUpdateFrequency = (LanguageSourceData.eGoogleUpdateFrequency)mProp_GoogleUpdateFrequency.enumValueIndex;
            GoogleUpdateFrequency = (LanguageSourceData.eGoogleUpdateFrequency)EditorGUILayout.EnumPopup("Auto Update Frequency", GoogleUpdateFrequency, GUILayout.ExpandWidth(true));
            if (EditorGUI.EndChangeCheck())
            {
                mProp_GoogleUpdateFrequency.enumValueIndex = (int)GoogleUpdateFrequency;
            }

            GUILayout.Space(10);
            GUILayout.Label("Delay:");
            mProp_GoogleUpdateDelay.floatValue = EditorGUILayout.FloatField(mProp_GoogleUpdateDelay.floatValue, GUILayout.Width(30));
            GUILayout.Label("secs");

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            var GoogleInEditorCheckFrequency = (LanguageSourceData.eGoogleUpdateFrequency)mProp_GoogleInEditorCheckFrequency.enumValueIndex;
            EditorGUI.BeginChangeCheck();
            GoogleInEditorCheckFrequency = (LanguageSourceData.eGoogleUpdateFrequency)EditorGUILayout.EnumPopup(new GUIContent("In-Editor Check Frequency", "How often the editor will verify that the Spreadsheet is up-to-date with the LanguageSource. Having un-synchronized Spreadsheets can lead to issues when playing in the device as the download data will override the one in the build"), GoogleInEditorCheckFrequency, GUILayout.ExpandWidth(false));
            if (EditorGUI.EndChangeCheck())
            {
                mProp_GoogleInEditorCheckFrequency.enumValueIndex = (int)GoogleInEditorCheckFrequency;
            }
            GUILayout.Space(122);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Update Synchronization", GUILayout.Width(180));
            EditorGUI.BeginChangeCheck();
            LanguageSourceData.eGoogleUpdateSynchronization GoogleUpdateSynchronization = (LanguageSourceData.eGoogleUpdateSynchronization)mProp_GoogleUpdateSynchronization.enumValueIndex;
            GoogleUpdateSynchronization = (LanguageSourceData.eGoogleUpdateSynchronization)EditorGUILayout.EnumPopup(GoogleUpdateSynchronization, GUILayout.Width(178));
            if (EditorGUI.EndChangeCheck())
            {
                mProp_GoogleUpdateSynchronization.enumValueIndex = (int)GoogleUpdateSynchronization;
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUI.changed = false;
            bool OpenDataSourceAfterExport = EditorPrefs.GetBool("I2Loc OpenDataSourceAfterExport", true);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            OpenDataSourceAfterExport = GUILayout.Toggle(OpenDataSourceAfterExport, "Open Spreadsheet after Export");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (GUI.changed)
            {
                GUI.changed = false;
                EditorPrefs.SetBool("I2Loc OpenDataSourceAfterExport", OpenDataSourceAfterExport);
            }
#endif

            GUILayout.Space(5);
        }
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            if (targets.Length != 1)
            {
                return;
            }

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            EditorGUILayout.LabelField("Waypoints", EditorStyles.boldLabel);

            var controller = (AIController)targets[0];

            if (controller.Waypoints != null)
            {
                int toDelete    = -1;
                int toMakeFirst = -1;

                if (GUILayout.Button("Reverse"))
                {
                    Undo.RecordObject(controller, "Reverse waypoints");

                    if (controller.Waypoints.Length == 2)
                    {
                        var t = controller.Waypoints[0];
                        controller.Waypoints[0] = controller.Waypoints[1];
                        controller.Waypoints[1] = t;
                    }
                    else if (controller.Waypoints.Length > 2)
                    {
                        for (int i = 1; i < controller.Waypoints.Length / 2 + 1; i++)
                        {
                            var t = controller.Waypoints[i];
                            controller.Waypoints[i] = controller.Waypoints[controller.Waypoints.Length - i];
                            controller.Waypoints[controller.Waypoints.Length - i] = t;
                        }
                    }

                    if (_lastSelectedWaypoint > 0)
                    {
                        _lastSelectedWaypoint = controller.Waypoints.Length - _lastSelectedWaypoint;
                    }
                }

                for (int i = 0; i < controller.Waypoints.Length; i++)
                {
                    EditorGUILayout.Space();

                    var isSelected = controller == _lastSelectedController && i == _lastSelectedWaypoint;

                    if (isSelected)
                    {
                        var oldColor = GUI.backgroundColor;
                        GUI.backgroundColor = Color.green;
                        EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                        GUI.backgroundColor = oldColor;
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                    }

                    var rect = EditorGUILayout.BeginVertical();
                    GUI.Box(rect, GUIContent.none);

                    controller.Waypoints[i].Position = EditorGUILayout.Vector3Field("Position", controller.Waypoints[i].Position);
                    controller.Waypoints[i].Pause    = EditorGUILayout.FloatField("Pause", controller.Waypoints[i].Pause);
                    controller.Waypoints[i].Run      = EditorGUILayout.Toggle("Run", controller.Waypoints[i].Run);

                    if (!isSelected)
                    {
                        if (GUILayout.Button("Select"))
                        {
                            _lastSelectedController = controller;
                            _lastSelectedWaypoint   = i;
                            SceneView.RepaintAll();
                        }
                    }

                    if (i > 0)
                    {
                        if (GUILayout.Button("Make First"))
                        {
                            toMakeFirst = i;
                        }
                    }

                    EditorGUILayout.EndVertical();

                    {
                        var oldColor = GUI.backgroundColor;
                        GUI.backgroundColor = Color.red;
                        if (GUILayout.Button("X", GUILayout.Width(20)))
                        {
                            toDelete = i;
                        }
                        GUI.backgroundColor = oldColor;
                    }

                    EditorGUILayout.EndHorizontal();
                }

                if (toDelete >= 0)
                {
                    deleteWaypoint(controller, toDelete);
                }

                if (toMakeFirst >= 0)
                {
                    Undo.RecordObject(controller, "Make waypoint first");

                    var old = controller.Waypoints;
                    controller.Waypoints = new Waypoint[old.Length];

                    for (int i = 0; i < old.Length; i++)
                    {
                        controller.Waypoints[i] = old[(toMakeFirst + i) % old.Length];
                    }

                    _lastSelectedWaypoint = 0;
                }
            }

            EditorGUILayout.Space();

            if (GUILayout.Button("Add Waypoint"))
            {
                if (controller.Waypoints == null)
                {
                    controller.Waypoints = new Waypoint[1];
                }
                else
                {
                    var old = controller.Waypoints;
                    controller.Waypoints = new Waypoint[old.Length + 1];

                    for (int i = 0; i < old.Length; i++)
                    {
                        controller.Waypoints[i] = old[i];
                    }
                }

                var value = new Waypoint();

                if (controller.Waypoints.Length > 1)
                {
                    value.Position = controller.Waypoints[controller.Waypoints.Length - 2].Position;
                }
                else
                {
                    value.Position = controller.transform.position;
                }

                controller.Waypoints[controller.Waypoints.Length - 1] = value;
            }
        }
Exemple #3
0
        /// <summary>
        /// Recursively draw properties of the given SerializedProperty data.
        /// </summary>
        public static void DrawSerializedProperty(SerializedProperty prop, GUIStyle guiStyle = null)
        {
            switch (prop.propertyType)
            {
                case SerializedPropertyType.Generic:
                    // make Array and Object to be fold
                    prop.isExpanded = EditorGUILayout.Foldout(prop.isExpanded, prop.displayName);
                    if (!prop.isExpanded)
                        break;

                    // increase indentation
                    EditorGUI.indentLevel++;
                    if (!prop.isArray)
                    {
                        // get Serializable Object
                        var child = prop.Copy();
                        var end = prop.GetEndProperty(true);
                        if (child.Next(true))
                        {
                            while (!SerializedProperty.EqualContents(child, end))
                            {
                                DrawSerializedProperty(child);
                                if (!child.Next(false))
                                    break;
                            }
                        }
                    }
                    else
                    {
                        // Handles array type with separate way due to SerializedProperty provides
                        // its own method for array type.
                        prop.arraySize = EditorGUILayout.IntField("Length", prop.arraySize);
                        var showCount = Mathf.Min(prop.arraySize, maxVisibleArrayElements);
                        for (int i = 0; i < showCount; i++)
                        {
                            if (guiStyle != null)
                            {
                                using (new GUILayout.VerticalScope(guiStyle))
                                {
                                    DrawSerializedProperty(prop.GetArrayElementAtIndex(i));
                                }
                            }
                            else
                                DrawSerializedProperty(prop.GetArrayElementAtIndex(i));
                        }
                        // Hide elements if it exceeds defined show count.
                        if (prop.arraySize > showCount)
                        {
                            using (new GUILayout.HorizontalScope())
                            {
                                // Do indentation
                                for (int i = 0; i < EditorGUI.indentLevel; i++)
                                {
                                    GUILayout.Space(EditorGUIUtility.singleLineHeight);
                                }
                                if (GUILayout.Button("Show more ..."))
                                {
                                    maxVisibleArrayElements += defaultVisibleArrayElements;
                                }
                            }
                        }
                    }
                    // decrease indentation
                    EditorGUI.indentLevel--;
                    break;
                case SerializedPropertyType.Integer:
                    prop.intValue = EditorGUILayout.IntField(prop.displayName, prop.intValue);
                    break;
                case SerializedPropertyType.Boolean:
                    prop.boolValue = EditorGUILayout.Toggle(prop.displayName, prop.boolValue);
                    break;
                case SerializedPropertyType.Float:
                    prop.floatValue = EditorGUILayout.FloatField(prop.displayName, prop.floatValue);
                    break;
                case SerializedPropertyType.String:
                    prop.stringValue = EditorGUILayout.TextField(prop.displayName, prop.stringValue);
                    break;
                case SerializedPropertyType.Color:
                    prop.colorValue = EditorGUILayout.ColorField(prop.displayName, prop.colorValue);
                    break;
                case SerializedPropertyType.ObjectReference:
                    prop.objectReferenceValue = EditorGUILayout.ObjectField(
                        prop.displayName, prop.objectReferenceValue, typeof(Object), true);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.LabelField("Type", prop.type);
                    EditorGUI.indentLevel--;
                    break;
                case SerializedPropertyType.LayerMask:
                    prop.intValue = EditorGUILayout.IntField(prop.displayName, prop.intValue);
                    break;
                case SerializedPropertyType.Enum:
                    EditorGUILayout.PropertyField(prop);
                    EditorGUI.indentLevel++;
                    EditorGUI.BeginDisabledGroup(true);
                    prop.enumValueIndex = EditorGUILayout.IntField(prop.name, prop.enumValueIndex);
                    EditorGUI.EndDisabledGroup();
                    EditorGUI.indentLevel--;
                    break;
                case SerializedPropertyType.Vector2:
                    prop.vector2Value = EditorGUILayout.Vector2Field(prop.displayName, prop.vector2Value);
                    break;
                case SerializedPropertyType.Vector3:
                    prop.vector3Value = EditorGUILayout.Vector3Field(prop.displayName, prop.vector3Value);
                    break;
                case SerializedPropertyType.Rect:
                    prop.rectValue = EditorGUILayout.RectField(prop.displayName, prop.rectValue);
                    break;
                case SerializedPropertyType.ArraySize:
                    prop.intValue = EditorGUILayout.IntField(prop.displayName, prop.intValue);
                    break;
                case SerializedPropertyType.Character:
                    EditorGUILayout.PropertyField(prop);
                    break;
                case SerializedPropertyType.AnimationCurve:
                    prop.animationCurveValue = EditorGUILayout.CurveField(prop.displayName, prop.animationCurveValue);
                    break;
                case SerializedPropertyType.Bounds:
                    prop.boundsValue = EditorGUILayout.BoundsField(prop.displayName, prop.boundsValue);
                    break;
                case SerializedPropertyType.Gradient:
                    EditorGUILayout.PropertyField(prop);
                    break;
                case SerializedPropertyType.Quaternion:
                    prop.quaternionValue = Quaternion.Euler(
                        EditorGUILayout.Vector3Field(prop.displayName, prop.quaternionValue.eulerAngles));
                    break;
            }
        }
    void AgentExtraSettings()
    {
        GUILayout.Space(2);
        EditorGUILayout.PropertyField(windw.Follower.FindPropertyRelative("UpdateType"));

        EditorGUILayout.BeginHorizontal();
        var oneDirectionContent = (windw.Follower.FindPropertyRelative("FlipDirection").boolValue ? SplinePlusEditor.On : SplinePlusEditor.Off);

        if (GUILayout.Button(new GUIContent(oneDirectionContent.image, "Flip direction"), GUIStyle.none, GUILayout.MaxWidth(40), GUILayout.MaxHeight(20)))
        {
            windw.Follower.FindPropertyRelative("FlipDirection").boolValue = !windw.Follower.FindPropertyRelative("FlipDirection").boolValue;
            windw.Follower.serializedObject.ApplyModifiedProperties();

            SPData.SplinePlus.PFFindAllShortestPaths();
        }

        EditorGUILayout.LabelField(new GUIContent("Flip direction"));
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        var isConsidTangentsContent = (windw.Follower.FindPropertyRelative("ConsiderTangents").boolValue) ? SplinePlusEditor.On : SplinePlusEditor.Off;

        if (GUILayout.Button(new GUIContent(isConsidTangentsContent.image, "Consider tangents"), GUIStyle.none, GUILayout.MaxWidth(40), GUILayout.MaxHeight(20)))
        {
            windw.Follower.FindPropertyRelative("ConsiderTangents").boolValue = !windw.Follower.FindPropertyRelative("ConsiderTangents").boolValue;
            windw.Follower.serializedObject.ApplyModifiedProperties();

            SPData.SplinePlus.PFFindAllShortestPaths();
        }
        EditorGUILayout.LabelField(new GUIContent("Consider tangents"));
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        var isMinDistContent = (windw.Follower.FindPropertyRelative("IsMinDist").boolValue) ? SplinePlusEditor.On : SplinePlusEditor.Off;

        if (GUILayout.Button(new GUIContent(isMinDistContent.image, "Enable/disable Min distance"), GUIStyle.none, GUILayout.MaxWidth(40), GUILayout.MaxHeight(20)))
        {
            windw.Follower.FindPropertyRelative("IsMinDist").boolValue = !windw.Follower.FindPropertyRelative("IsMinDist").boolValue;
            windw.Follower.serializedObject.ApplyModifiedProperties();

            SPData.SplinePlus.PFFindAllShortestPaths();
        }

        if (windw.Follower.FindPropertyRelative("IsMinDist").boolValue)
        {
            EditorGUI.BeginChangeCheck();
            var minDist = EditorGUILayout.FloatField(new GUIContent("Min Distance"), windw.Follower.FindPropertyRelative("MinDistance").floatValue);
            if (EditorGUI.EndChangeCheck())
            {
                windw.Follower.FindPropertyRelative("MinDistance").floatValue = minDist;
                windw.Follower.serializedObject.ApplyModifiedProperties();

                SPData.SplinePlus.PFFindAllShortestPaths();
            }
        }
        else
        {
            EditorGUILayout.LabelField(new GUIContent("Min Distance"));
        }
        EditorGUILayout.EndHorizontal();
    }
Exemple #5
0
        public static void DrawArray(Array array, params GUILayoutOption[] options)
        {
            EditorGUILayout.BeginVertical();
            //Space(3);
            Type type = array.GetType().GetElementType();

            for (int i = 0; i < array.Length; i++)
            {
                EditorGUILayout.BeginHorizontal();
                var oldValue = array.GetValue(i);
                if (type == typeof(int))
                {
                    var newValue = EditorGUILayout.IntField(i.ToString(), (int)oldValue, options);
                    if (newValue != (int)oldValue)
                    {
                        array.SetValue(newValue, i);
                    }
                }
                else if (type == typeof(float))
                {
                    var newValue = EditorGUILayout.FloatField(i.ToString(), (float)oldValue, options);
                    if (newValue != (float)oldValue)
                    {
                        array.SetValue(newValue, i);
                    }
                }
                else if (type == typeof(FP))
                {
                    float oldFloatValue = ((FP)oldValue).AsFloat();
                    float newFloatValue = EditorGUILayout.FloatField(i.ToString(), oldFloatValue, options);
                    var   newValue      = FP.FromFloat(newFloatValue);
                    if (newValue != (FP)oldValue)
                    {
                        array.SetValue(newValue, i);
                    }
                }
                else if (type == typeof(bool))
                {
                    var newValue = EditorGUILayout.Toggle(i.ToString(), (bool)oldValue, options);
                    if (newValue != (bool)oldValue)
                    {
                        array.SetValue(newValue, i);
                    }
                }
                else if (type == typeof(string))
                {
                    var newValue = EditorGUILayout.TextField(i.ToString(), (string)oldValue, options);
                    if (newValue != (string)oldValue)
                    {
                        array.SetValue(newValue, i);
                    }
                }
                else if (type == typeof(Vector2))
                {
                    var newValue = EditorGUILayout.Vector2Field(i.ToString(), (Vector2)oldValue, options);
                    if (newValue != (Vector2)oldValue)
                    {
                        array.SetValue(newValue, i);
                    }
                }
                else if (type == typeof(Vector3))
                {
                    var newValue = EditorGUILayout.Vector3Field(i.ToString(), (Vector3)oldValue, options);
                    if (newValue != (Vector3)oldValue)
                    {
                        array.SetValue(newValue, i);
                    }
                }
                else if (type.IsEnum)
                {
                    var newValue = EditorGUILayout.EnumPopup(i.ToString(), (Enum)oldValue, options);
                    if (newValue != (Enum)oldValue)
                    {
                        array.SetValue(newValue, i);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
Exemple #6
0
    private static bool showAddValueOptions(ref DistanceValueList distanceValueList, DistanceValueType distanceValueType)
    {
        useEndDistance = GUILayout.Toggle(useEndDistance, "Use End Distance");

        GUILayout.BeginHorizontal();
        GUILayout.Label("Start Distance", GUILayout.Width(100));
        startDistance = EditorGUILayout.IntField(startDistance);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label(string.Format("{0}{1}", distanceValueType != DistanceValueType.Section ? "Start " : "", Enum.GetName(typeof(DistanceValueType), (int)distanceValueType)), GUILayout.Width(100));
        if (distanceValueType == DistanceValueType.Probability)
        {
            startValue = GUILayout.HorizontalSlider(startValue, 0, 1, GUILayout.Width(100));
            GUILayout.Label(Math.Round(startValue, 2).ToString());
        }
        else if (distanceValueType == DistanceValueType.Speed)
        {
            startValue = EditorGUILayout.FloatField(startValue);
        }
        else     // section
        {
            startValue = EditorGUILayout.IntField((int)startValue);
        }
        GUILayout.EndHorizontal();

        if (useEndDistance)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("End Distance", GUILayout.Width(100));
            endDistance = EditorGUILayout.IntField(endDistance);
            GUILayout.EndHorizontal();

            if (distanceValueType != DistanceValueType.Section)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Format("End {0}", Enum.GetName(typeof(DistanceValueType), (int)distanceValueType)), GUILayout.Width(100));
                if (distanceValueType == DistanceValueType.Probability)
                {
                    endValue = GUILayout.HorizontalSlider(endValue, 0, 1, GUILayout.Width(100));
                    GUILayout.Label(Math.Round(endValue, 2).ToString());
                }
                else if (distanceValueType == DistanceValueType.Speed)
                {
                    endValue = EditorGUILayout.FloatField(endValue);
                }
                GUILayout.EndHorizontal();
            }
        }

        if (addError.Length > 0)
        {
            GUI.contentColor = Color.red;
            GUILayout.Label(addError);
            GUI.contentColor = Color.white;
        }

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Add"))
        {
            int error;
            if ((error = addValue(ref distanceValueList)) == 0)
            {
                addNewValue = false;
                return(true);
            }
            else
            {
                switch (error)
                {
                case 1:
                    addError = "Error: Start distance must be\ngreater than end distance";
                    break;

                case 2:
                    addError = string.Format("Error: The {0} distances overlap\na different set of {0} distances", Enum.GetName(typeof(DistanceValueType), (int)distanceValueType).ToLower());
                    break;

                case 3:
                    addError = string.Format("Error: Another {0} already exists\nwhich does not have the end distance set", Enum.GetName(typeof(DistanceValueType), (int)distanceValueType).ToLower());
                    break;

                default:
                    addError = "Unknown Error";
                    break;
                }
            }
        }

        if (GUILayout.Button("Cancel"))
        {
            addNewValue = false;
        }
        GUILayout.EndHorizontal();
        return(false);
    }
    void SharedSettings()
    {
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(windw.Follower.FindPropertyRelative("_FollowerAnimation"), new GUIContent("Animation type"));
        if (EditorGUI.EndChangeCheck())
        {
            if (windw.followerSettingsType != FollowerSettingsType.Follower && windw.Follower.FindPropertyRelative("_FollowerAnimation").intValue == 2
                )
            {
                windw.Follower.FindPropertyRelative("_FollowerAnimation").intValue = 0;
            }
        }
        GUILayout.Space(2);


        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

        EditorGUILayout.LabelField("Extra settings", EditorStyles.boldLabel);
        if (windw.Follower.FindPropertyRelative("_FollowerAnimation").enumValueIndex != (int)FollowerAnimation.SceneClick)
        {
            EditorGUI.BeginChangeCheck();
            var acceleration = EditorGUILayout.FloatField("Acceleration", windw.Follower.FindPropertyRelative("Acceleration").floatValue);
            if (EditorGUI.EndChangeCheck())
            {
                if (acceleration < 0)
                {
                    acceleration = 0;
                }
                windw.Follower.FindPropertyRelative("Acceleration").floatValue = acceleration;
            }
            if (windw.followerSettingsType == FollowerSettingsType.Agent)
            {
                EditorGUI.BeginChangeCheck();
                var brakesForce = EditorGUILayout.FloatField("Brakes force", windw.Follower.FindPropertyRelative("BrakesForce").floatValue);
                if (EditorGUI.EndChangeCheck())
                {
                    if (brakesForce < 1)
                    {
                        brakesForce = 1;
                    }
                    windw.Follower.FindPropertyRelative("BrakesForce").floatValue = brakesForce;
                }
            }
        }

        if (windw.Follower.FindPropertyRelative("_FollowerAnimation").enumValueIndex == (int)FollowerAnimation.KeyboardInput)
        {
            EditorGUI.BeginChangeCheck();
            var brakesForce = EditorGUILayout.FloatField("Brakes force", windw.Follower.FindPropertyRelative("BrakesForce").floatValue);
            if (EditorGUI.EndChangeCheck())
            {
                if (brakesForce < 1)
                {
                    brakesForce = 1;
                }
                windw.Follower.FindPropertyRelative("BrakesForce").floatValue = brakesForce;
            }

            if (windw.followerSettingsType == FollowerSettingsType.Follower)
            {
                EditorGUILayout.BeginHorizontal();
                var flipDirectionContent = (windw.Follower.FindPropertyRelative("FlipDirection").boolValue ? SplinePlusEditor.On : SplinePlusEditor.Off);
                if (GUILayout.Button(new GUIContent(flipDirectionContent.image, "Flip direction"), GUIStyle.none, GUILayout.MaxWidth(40), GUILayout.MaxHeight(20)))
                {
                    windw.Follower.FindPropertyRelative("FlipDirection").boolValue = !windw.Follower.FindPropertyRelative("FlipDirection").boolValue;
                    windw.Follower.serializedObject.ApplyModifiedProperties();

                    SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData);
                }
                EditorGUILayout.LabelField(new GUIContent("Flip direction"));
                EditorGUILayout.EndHorizontal();
            }
        }



        if (windw.followerSettingsType == FollowerSettingsType.Follower)
        {
            PathFollowingType();
        }
        if (windw.followerSettingsType == FollowerSettingsType.Agent)
        {
            AgentExtraSettings();
        }

        EditorGUILayout.EndVertical();
        AnimationEvents();
    }
        //===========================================================================================

        /**
         *  @brief
         *
         *********************************************************************************************/
        public void OnGUI(Rect a_position)
        {
            if (m_data == null)
            {
                MxMSettings settings = MxMSettings.Instance();
                if (settings != null)
                {
                    m_data = settings.ActiveBlendSpace;

                    if (m_data != null)
                    {
                        SetData(m_data);
                    }
                }
            }

            if (m_data != null)
            {
                Event evt = Event.current;

                float labelWidth = EditorGUIUtility.labelWidth;

                if (evt.type == EventType.Repaint)
                {
                    if (m_queueDeleteIndex >= 0 && m_queueDeleteIndex < m_spClips.arraySize)
                    {
                        if (m_selectId == m_queueDeleteIndex)
                        {
                            m_selectId = -1;
                        }

                        if (m_spClips.GetArrayElementAtIndex(m_queueDeleteIndex).objectReferenceValue != null)
                        {
                            m_spClips.DeleteArrayElementAtIndex(m_queueDeleteIndex);
                        }

                        m_spClips.DeleteArrayElementAtIndex(m_queueDeleteIndex);
                        m_spPositions.DeleteArrayElementAtIndex(m_queueDeleteIndex);

                        m_queueDeleteIndex = -1;
                    }
                }

                EditorGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Height(20f), GUILayout.ExpandWidth(true));

                EditorGUI.BeginChangeCheck();
                m_previewActive = GUILayout.Toggle(m_previewActive, "Preview", EditorStyles.toolbarButton, GUILayout.Width(60f));
                if (EditorGUI.EndChangeCheck())
                {
                    if (m_previewActive)
                    {
                        BeginPreview();
                    }
                    else
                    {
                        EndPreview();
                    }
                }



                if (m_previewActive && MxMPreviewScene.IsSceneLoaded)
                {
                    EditorGUIUtility.labelWidth = 20f;

                    EditorGUI.BeginChangeCheck();
                    m_previewPos.x = EditorGUILayout.FloatField("X: ", m_previewPos.x, EditorStyles.toolbarTextField);
                    m_previewPos.y = EditorGUILayout.FloatField("Y: ", m_previewPos.y, EditorStyles.toolbarTextField);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_previewPos.x = Mathf.Clamp(m_previewPos.x, -1f, 1f);
                        m_previewPos.y = Mathf.Clamp(m_previewPos.y, -1f, 1f);

                        CalculateBlendWeights();
                        ApplyBlendWeights();
                    }
                    EditorGUIUtility.labelWidth = labelWidth;

                    UpdatePreview();
                    MxMAnimConfigWindow.Inst().Repaint();
                }

                GUILayout.FlexibleSpace();

                m_spNormalizeTime.boolValue = GUILayout.Toggle(m_spNormalizeTime.boolValue, "Normalize Time",
                                                               EditorStyles.toolbarButton, GUILayout.Width(90f));

                EditorGUILayout.LabelField("Type:", GUILayout.Width(40f));
                m_spScatterSpace.enumValueIndex = (int)(EBlendSpaceType)EditorGUILayout.EnumPopup(
                    (EBlendSpaceType)m_spScatterSpace.enumValueIndex, GUILayout.Width(70f));
                GUILayout.Space(5f);

                switch ((EBlendSpaceType)m_spScatterSpace.enumValueIndex)
                {
                case EBlendSpaceType.Standard:
                {
                    EditorGUILayout.LabelField("Magnitude ", GUILayout.Width(62f));
                    m_spMagnitude.vector2Value = EditorGUILayout.Vector2Field("", m_spMagnitude.vector2Value, GUILayout.Width(100f));
                    EditorGUILayout.LabelField("Smoothing ", GUILayout.Width(65f));
                    m_spSmoothing.vector2Value = EditorGUILayout.Vector2Field("", m_spSmoothing.vector2Value, GUILayout.Width(100f));
                }
                break;

                case EBlendSpaceType.Scatter:
                {
                    EditorGUILayout.LabelField("Spacing", GUILayout.Width(50f));
                    m_spScatterSpacing.vector2Value = EditorGUILayout.Vector2Field("", m_spScatterSpacing.vector2Value, GUILayout.Width(100f));
                }
                break;

                case EBlendSpaceType.ScatterX:
                {
                    EditorGUILayout.LabelField("Spacing X", GUILayout.Width(60f));
                    float spacingX = EditorGUILayout.FloatField(m_spScatterSpacing.vector2Value.x, GUILayout.Width(35f));

                    m_spScatterSpacing.vector2Value = new Vector2(spacingX, m_spScatterSpacing.vector2Value.y);
                }
                break;

                case EBlendSpaceType.ScatterY:
                {
                    EditorGUILayout.LabelField("Spacing Y", GUILayout.Width(60f));
                    float spacingY = EditorGUILayout.FloatField(m_spScatterSpacing.vector2Value.y, GUILayout.Width(35f));

                    m_spScatterSpacing.vector2Value = new Vector2(m_spScatterSpacing.vector2Value.x, spacingY);
                }
                break;
                }



                GUILayout.Space(2f);
                m_showClipNames = GUILayout.Toggle(m_showClipNames, "Show Clips", EditorStyles.toolbarButton, GUILayout.Width(80f));
                GUILayout.Space(5f);
                m_snapActive = GUILayout.Toggle(m_snapActive, "Snap", EditorStyles.toolbarButton, GUILayout.Width(40f));

                if (m_snapActive)
                {
                    m_snapInterval = EditorGUILayout.FloatField(m_snapInterval, EditorStyles.toolbarTextField, GUILayout.Width(30f));
                }

                EditorGUILayout.EndHorizontal();
                GUILayout.FlexibleSpace();

                EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.Height(20f), GUILayout.ExpandWidth(true));

                if (m_selectId >= 0 && m_selectId < m_spClips.arraySize)
                {
                    AnimationClip      clip       = m_spClips.GetArrayElementAtIndex(m_selectId).objectReferenceValue as AnimationClip;
                    SerializedProperty spPosition = m_spPositions.GetArrayElementAtIndex(m_selectId);

                    if (clip != null && spPosition != null)
                    {
                        EditorGUILayout.LabelField(clip.name, GUILayout.Width(GUI.skin.label.CalcSize(new GUIContent(clip.name)).x + 4f));

                        EditorGUI.BeginChangeCheck();
                        spPosition.vector2Value = EditorGUILayout.Vector2Field("", spPosition.vector2Value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (m_previewActive && MxMPreviewScene.IsSceneLoaded)
                            {
                                CalculateBlendWeights();
                                ApplyBlendWeights();
                            }
                        }
                    }
                }

                EditorGUILayout.LabelField("Require", GUILayout.Width(50f));
                MxMPreProcessData preProcessData = m_spTargetPreProcessData.objectReferenceValue as MxMPreProcessData;
                AnimationModule   animModule     = m_spTargetAnimModule.objectReferenceValue as AnimationModule;

                if (preProcessData != null)
                {
                    EditorFunctions.DrawTagFlagFieldWithCustomNames(preProcessData.TagNames.ToArray(), m_spGlobalTags, 100f);
                }
                else if (animModule != null && animModule.TagNames != null)
                {
                    EditorFunctions.DrawTagFlagFieldWithCustomNames(animModule.TagNames.ToArray(), m_spGlobalTags, 100f);
                }
                else
                {
                    m_spGlobalTags.intValue = (int)(ETags)EditorGUILayout.EnumFlagsField((ETags)m_spGlobalTags.intValue);
                }

                EditorGUILayout.LabelField("Favour", GUILayout.Width(45f));

                if (preProcessData != null)
                {
                    EditorFunctions.DrawTagFlagFieldWithCustomNames(preProcessData.FavourTagNames.ToArray(), m_spGlobalFavourTags, 100f);
                }
                else if (animModule != null && animModule.FavourTagNames != null)
                {
                    EditorFunctions.DrawTagFlagFieldWithCustomNames(animModule.FavourTagNames.ToArray(), m_spGlobalFavourTags, 100f);
                }
                else
                {
                    m_spGlobalFavourTags.intValue = (int)(ETags)EditorGUILayout.EnumFlagsField((ETags)m_spGlobalFavourTags.intValue);
                }

                GUILayout.FlexibleSpace();

                if (GUILayout.Button(new GUIContent("Open Timeline"), EditorStyles.toolbarButton))
                {
                    MxMTaggingWindow.ShowWindow();
                }

                GUILayout.Space(5f);

                if (m_spTargetPreProcessData.objectReferenceValue != null ||
                    m_spTargetAnimModule.objectReferenceValue != null)
                {
                    if (GUILayout.Button(EditorGUIUtility.IconContent("back").image, EditorStyles.toolbarButton))
                    {
                        LastBlendSpace();
                    }

                    if (GUILayout.Button(EditorGUIUtility.IconContent("forward").image, EditorStyles.toolbarButton))
                    {
                        NextBlendSpace();
                    }
                }

                EditorGUI.BeginDisabledGroup(true);

                EditorGUIUtility.labelWidth = 110f;
                if (preProcessData != null)
                {
                    EditorGUILayout.ObjectField(m_spTargetPreProcessData, new GUIContent("Target PreProcess"));
                }
                else if (animModule != null)
                {
                    EditorGUILayout.ObjectField(m_spTargetAnimModule, new GUIContent("Target Anim Module"));
                }

                EditorGUIUtility.labelWidth = 95f;
                EditorGUILayout.ObjectField(m_spTargetPrefab, new GUIContent("Preview Prefab"));

                EditorGUI.EndDisabledGroup();

                EditorGUIUtility.labelWidth = labelWidth;

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();

                Rect blendSpaceRect = new Rect(30f, 40f, a_position.width - 60f, a_position.height - 90f);

                GUI.Box(blendSpaceRect, "");

                Rect labelRect = new Rect(blendSpaceRect.x - 18f, blendSpaceRect.y, 18f, 18f);

                GUI.Label(labelRect, "1");
                labelRect.y += blendSpaceRect.height / 2f - 9f;
                GUI.Label(labelRect, "0");
                labelRect.y = blendSpaceRect.y + blendSpaceRect.height - 18f;
                GUI.Label(labelRect, "-1");
                labelRect.y += labelRect.height;
                labelRect.x += labelRect.width;
                GUI.Label(labelRect, "-1");
                labelRect.x += blendSpaceRect.width / 2f - 9f;
                GUI.Label(labelRect, "0");
                labelRect.x = blendSpaceRect.x + blendSpaceRect.width - 18f;
                GUI.Label(labelRect, "1");

                float spacingH = blendSpaceRect.width / 10f;
                float spacingV = blendSpaceRect.height / 10f;

                float top    = blendSpaceRect.y;
                float bottom = blendSpaceRect.y + blendSpaceRect.height;
                float left   = blendSpaceRect.x;
                float right  = blendSpaceRect.x + blendSpaceRect.width;

                Handles.color = Color.grey;
                for (int i = 1; i < 10; ++i)
                {
                    float horizontal = i * spacingH + blendSpaceRect.x;
                    float vertical   = i * spacingV + blendSpaceRect.y;

                    Handles.DrawLine(new Vector3(horizontal, top), new Vector3(horizontal, bottom));
                    Handles.DrawLine(new Vector3(left, vertical), new Vector3(right, vertical));
                }

                Handles.color = Color.black;
                Handles.DrawLine(new Vector3(blendSpaceRect.x + blendSpaceRect.width / 2f, top),
                                 new Vector3(blendSpaceRect.x + blendSpaceRect.width / 2f, bottom));

                Handles.DrawLine(new Vector3(left, blendSpaceRect.y + blendSpaceRect.height / 2f),
                                 new Vector3(right, blendSpaceRect.y + blendSpaceRect.height / 2f));

                Rect    animDrawRect    = new Rect(0f, 0f, 18f, 18f);
                Vector2 blendSpaceRatio = new Vector2(2f / blendSpaceRect.width, 2f / blendSpaceRect.height);

                Texture blendKey         = EditorGUIUtility.IconContent("blendKey").image;
                Texture blendKeySelected = EditorGUIUtility.IconContent("blendKeySelected").image;
                Texture previewPointTex  = EditorGUIUtility.IconContent("d_P4_AddedLocal").image;

                Vector2 centerPos = blendSpaceRect.position;
                centerPos.x += blendSpaceRect.width / 2f;
                centerPos.y += blendSpaceRect.height / 2f;

                //Draw Points
                for (int i = 0; i < m_spClips.arraySize; ++i)
                {
                    Vector2 normalizedPos = m_spPositions.GetArrayElementAtIndex(i).vector2Value;
                    normalizedPos.y *= -1f;

                    animDrawRect.position = (normalizedPos / blendSpaceRatio) + centerPos;

                    animDrawRect.size = new Vector2(14f, 14f);

                    if (m_previewActive && MxMPreviewScene.IsSceneLoaded)
                    {
                        float size = 9f + 5f * m_blendWeights[i];
                        animDrawRect.size = new Vector2(size, size);
                    }
                    else
                    {
                        animDrawRect.size = new Vector2(14f, 14f);
                    }

                    animDrawRect.position -= (animDrawRect.size / 2f);

                    if (m_selectId == i)
                    {
                        GUI.DrawTexture(animDrawRect, blendKeySelected);
                    }
                    else
                    {
                        GUI.DrawTexture(animDrawRect, blendKey);
                    }

                    if (m_showClipNames)
                    {
                        AnimationClip clip = m_spClips.GetArrayElementAtIndex(i).objectReferenceValue as AnimationClip;

                        Vector2 labelSize = GUI.skin.label.CalcSize(new GUIContent(clip.name));

                        Rect clipNameRect = new Rect(animDrawRect.x + (animDrawRect.width / 2f) - labelSize.x / 2f,
                                                     animDrawRect.y - labelSize.y, labelSize.x, labelSize.y);

                        GUI.Label(clipNameRect, clip.name);
                    }

                    if (evt.type == EventType.MouseDown && evt.button == 0)
                    {
                        if (animDrawRect.Contains(evt.mousePosition))
                        {
                            m_selectId       = i;
                            m_dragging       = true;
                            m_cumulativeDrag = m_spPositions.GetArrayElementAtIndex(i).vector2Value;

                            if (evt.clickCount >= 2)
                            {
                                EditorGUIUtility.PingObject(m_spClips.GetArrayElementAtIndex(i).objectReferenceValue);
                            }

                            evt.Use();
                            MxMAnimConfigWindow.Inst().Repaint();
                        }
                    }
                }

                //Draw Preview Point
                if (m_previewActive && MxMPreviewScene.IsSceneLoaded)
                {
                    Vector3 previewDrawPos = m_previewPos;
                    previewDrawPos.y *= -1f;

                    animDrawRect.size     = new Vector2(18f, 18f);
                    animDrawRect.position = (previewDrawPos / blendSpaceRatio) + centerPos - (animDrawRect.size / 2f);

                    GUI.DrawTexture(animDrawRect, previewPointTex);
                }

                switch (evt.type)
                {
                case EventType.MouseDown:
                {
                    if (m_previewActive && blendSpaceRect.Contains(evt.mousePosition) && MxMPreviewScene.IsSceneLoaded)
                    {
                        Vector2 blendSpacePos = evt.mousePosition - (blendSpaceRect.position + (blendSpaceRect.size / 2f));
                        m_previewPos    = blendSpacePos * blendSpaceRatio;
                        m_previewPos.y *= -1f;

                        m_previewPos.x = Mathf.Clamp(m_previewPos.x, -1f, 1f);
                        m_previewPos.y = Mathf.Clamp(m_previewPos.y, -1f, 1f);

                        CalculateBlendWeights();
                        ApplyBlendWeights();


                        m_draggingPreview = true;
                    }

                    m_dragging = false;
                    m_selectId = -1;
                    evt.Use();
                }
                break;

                case EventType.MouseUp:
                {
                    if (m_dragging || m_draggingPreview)
                    {
                        m_draggingPreview = false;
                        m_dragging        = false;
                        m_cumulativeDrag  = Vector2.zero;
                        evt.Use();
                    }
                }
                break;

                case EventType.MouseDrag:
                {
                    if (m_dragging)
                    {
                        if (m_selectId >= 0 && m_selectId < m_spPositions.arraySize)
                        {
                            SerializedProperty spPosition = m_spPositions.GetArrayElementAtIndex(m_selectId);
                            Vector2            moveDelta  = evt.delta;
                            moveDelta.y *= -1f;

                            if (m_snapActive)
                            {
                                m_cumulativeDrag += moveDelta * blendSpaceRatio;

                                m_cumulativeDrag.x = Mathf.Clamp(m_cumulativeDrag.x, -1f, 1f);
                                m_cumulativeDrag.y = Mathf.Clamp(m_cumulativeDrag.y, -1f, 1f);

                                spPosition.vector2Value = m_cumulativeDrag;
                                SnapClip(m_selectId);
                            }
                            else
                            {
                                Vector2 newPos = spPosition.vector2Value + moveDelta * blendSpaceRatio;

                                newPos.x = Mathf.Clamp(newPos.x, -1f, 1f);
                                newPos.y = Mathf.Clamp(newPos.y, -1f, 1f);
                                spPosition.vector2Value = newPos;
                            }

                            if (m_previewActive && MxMPreviewScene.IsSceneLoaded)
                            {
                                CalculateBlendWeights();
                                ApplyBlendWeights();
                            }

                            evt.Use();
                        }
                        else
                        {
                            m_dragging = false;
                        }
                    }
                    else if (m_previewActive && m_draggingPreview && MxMPreviewScene.IsSceneLoaded)
                    {
                        Vector2 blendSpacePos = evt.mousePosition - (blendSpaceRect.position + (blendSpaceRect.size / 2f));
                        m_previewPos    = blendSpacePos * blendSpaceRatio;
                        m_previewPos.y *= -1f;

                        m_previewPos.x = Mathf.Clamp(m_previewPos.x, -1f, 1f);
                        m_previewPos.y = Mathf.Clamp(m_previewPos.y, -1f, 1f);

                        CalculateBlendWeights();
                        ApplyBlendWeights();

                        if (m_snapActive)
                        {
                            SnapPreview();
                        }

                        evt.Use();
                    }
                }
                break;

                case EventType.KeyDown:
                {
                    if (m_selectId >= 0 && m_selectId < m_spClips.arraySize)
                    {
                        if (evt.keyCode == KeyCode.Delete)
                        {
                            m_queueDeleteIndex = m_selectId;
                            MxMAnimConfigWindow.Inst().Repaint();
                            evt.Use();
                        }
                    }
                }
                break;
                }

                DragDropAnimations(blendSpaceRect);

                if (m_soData != null)
                {
                    m_soData.ApplyModifiedProperties();
                }
            }
            else
            {
                GUILayout.Space(18f);
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUILayout.LabelField("No Blend Space Selected.", EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
            }
        }
Exemple #9
0
        private static void OnGUI()
        {
            if (CinemachineHeader != null)
            {
                const float kWidth      = 350f;
                float       aspectRatio = (float)CinemachineHeader.height / (float)CinemachineHeader.width;
                GUILayout.BeginScrollView(Vector2.zero, false, false, GUILayout.Width(kWidth), GUILayout.Height(kWidth * aspectRatio));
                Rect texRect = new Rect(0f, 0f, kWidth, kWidth * aspectRatio);

                GUILayout.BeginArea(texRect);
                GUI.DrawTexture(texRect, CinemachineHeader, ScaleMode.ScaleToFit);
                GUILayout.EndArea();

                GUILayout.EndScrollView();
            }

            sScrollPosition = GUILayout.BeginScrollView(sScrollPosition);

            //CinemachineCore.sShowHiddenObjects
            //    = EditorGUILayout.Toggle("Show Hidden Objects", CinemachineCore.sShowHiddenObjects);

            ShowCoreSettings = EditorGUILayout.Foldout(ShowCoreSettings, "Runtime Settings");
            if (ShowCoreSettings)
            {
                EditorGUI.indentLevel++;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                Color newActiveGizmoColour = EditorGUILayout.ColorField(sCoreActiveGizmosColour, CinemachineCoreSettings.ActiveGizmoColour);

                if (EditorGUI.EndChangeCheck())
                {
                    CinemachineCoreSettings.ActiveGizmoColour = newActiveGizmoColour;
                    UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
                }

                if (GUILayout.Button("Reset"))
                {
                    CinemachineCoreSettings.ActiveGizmoColour = CinemachineCoreSettings.kDefaultActiveColour;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                Color newInactiveGizmoColour = EditorGUILayout.ColorField(sCoreInactiveGizmosColour, CinemachineCoreSettings.InactiveGizmoColour);

                if (EditorGUI.EndChangeCheck())
                {
                    CinemachineCoreSettings.InactiveGizmoColour = newInactiveGizmoColour;
                    UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
                }

                if (GUILayout.Button("Reset"))
                {
                    CinemachineCoreSettings.InactiveGizmoColour = CinemachineCoreSettings.kDefaultInactiveColour;
                }
                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }

            ShowComposerSettings = EditorGUILayout.Foldout(ShowComposerSettings, "Composer Settings");
            if (ShowComposerSettings)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();

                float overlayOpacity = EditorGUILayout.Slider(sComposerOverlayOpacity, ComposerSettings.OverlayOpacity, 0f, 1f);

                if (EditorGUI.EndChangeCheck())
                {
                    ComposerSettings.OverlayOpacity = overlayOpacity;
                }

                if (GUILayout.Button("Reset"))
                {
                    ComposerSettings.OverlayOpacity = ComposerSettings.kDefaultOverlayOpacity;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                Color newHardEdgeColor = EditorGUILayout.ColorField(sComposerHardBoundsOverlay, ComposerSettings.HardBoundsOverlayColour);

                if (EditorGUI.EndChangeCheck())
                {
                    ComposerSettings.HardBoundsOverlayColour = newHardEdgeColor;
                }

                if (GUILayout.Button("Reset"))
                {
                    ComposerSettings.HardBoundsOverlayColour = ComposerSettings.kDefaultHardBoundsColour;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                Color newSoftEdgeColor = EditorGUILayout.ColorField(sComposerSoftBoundsOverlay, ComposerSettings.SoftBoundsOverlayColour);

                if (EditorGUI.EndChangeCheck())
                {
                    ComposerSettings.SoftBoundsOverlayColour = newSoftEdgeColor;
                }

                if (GUILayout.Button("Reset"))
                {
                    ComposerSettings.SoftBoundsOverlayColour = ComposerSettings.kDefaultSoftBoundsColour;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                Color newTargetColour = EditorGUILayout.ColorField(sComposerTargetOverlay, ComposerSettings.TargetColour);

                if (EditorGUI.EndChangeCheck())
                {
                    ComposerSettings.TargetColour = newTargetColour;
                }

                if (GUILayout.Button("Reset"))
                {
                    ComposerSettings.TargetColour = ComposerSettings.kDefaultTargetColour;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUI.BeginChangeCheck();
                float targetSide = EditorGUILayout.FloatField(sComposerTargetOverlayPixels, ComposerSettings.TargetSize);

                if (EditorGUI.EndChangeCheck())
                {
                    ComposerSettings.TargetSize = targetSide;
                }
                EditorGUI.indentLevel--;
            }

            if (AdditionalCategories != null)
            {
                AdditionalCategories();
            }

            GUILayout.EndScrollView();

            //if (GUILayout.Button("Open Documentation"))
            //{
            //    Application.OpenURL(kCinemachineDocURL);
            //}
        }
Exemple #10
0
    protected void EmitterConfig(EffectLayer ctarget)
    {
        DisplayEmitterConfig = EditorGUILayout.Foldout(DisplayEmitterConfig, "Emitter Configuration");

        if (DisplayEmitterConfig)
        {
            EditorGUILayout.BeginVertical();

            ctarget.EmitType = EditorGUILayout.Popup("emitter type:", ctarget.EmitType, EmitTypes);
            if (ctarget.EmitType == 0)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("emit position:", ctarget.EmitPoint);
            }
            else if (ctarget.EmitType == 1)
            {
                ctarget.EmitPoint          = EditorGUILayout.Vector3Field("box center:", ctarget.EmitPoint);
                ctarget.BoxSize            = EditorGUILayout.Vector3Field("box size:", ctarget.BoxSize);
                ctarget.BoxInheritRotation = EditorGUILayout.Toggle("inherit rotation?", ctarget.BoxInheritRotation);
            }
            else if (ctarget.EmitType == 2)
            {
                ctarget.EmitPoint = EditorGUILayout.Vector3Field("sphere center:", ctarget.EmitPoint);
                ctarget.Radius    = EditorGUILayout.FloatField("radius:", ctarget.Radius);
            }
            else if (ctarget.EmitType == 3)
            {
                ctarget.EmitPoint   = EditorGUILayout.Vector3Field("circle center:", ctarget.EmitPoint);
                ctarget.CircleDir   = EditorGUILayout.Vector3Field("circle direction:", ctarget.CircleDir);
                ctarget.Radius      = EditorGUILayout.FloatField("radius:", ctarget.Radius);
                ctarget.EmitUniform = EditorGUILayout.Toggle("emit uniformly?", ctarget.EmitUniform);
            }
            else if (ctarget.EmitType == 4)
            {
                ctarget.EmitPoint       = EditorGUILayout.Vector3Field("line center:", ctarget.EmitPoint);
                ctarget.LineLengthLeft  = EditorGUILayout.FloatField("line left length:", ctarget.LineLengthLeft);
                ctarget.LineLengthRight = EditorGUILayout.FloatField("line right length:", ctarget.LineLengthRight);
                EditorGUILayout.LabelField("[line direction is based on client's forward direction.]");
            }
            else if (ctarget.EmitType == 5)
            {
                ctarget.EmitMesh     = (Mesh)EditorGUILayout.ObjectField("mesh", ctarget.EmitMesh, typeof(Mesh), true);
                ctarget.EmitMeshType = EditorGUILayout.Popup("mesh emit pos:", ctarget.EmitMeshType, EmitMeshType);
                ctarget.EmitUniform  = EditorGUILayout.Toggle("emit uniform?", ctarget.EmitUniform);
            }
            EditorGUILayout.Space();

            ctarget.MaxENodes      = EditorGUILayout.IntField("max nodes:", ctarget.MaxENodes);
            ctarget.IsNodeLifeLoop = EditorGUILayout.Toggle("is node life loop:", ctarget.IsNodeLifeLoop);
            if (!ctarget.IsNodeLifeLoop)
            {
                ctarget.NodeLifeMin = EditorGUILayout.FloatField("node life min:", ctarget.NodeLifeMin);
                ctarget.NodeLifeMax = EditorGUILayout.FloatField("node life max:", ctarget.NodeLifeMax);
            }

            ctarget.IsEmitByDistance = EditorGUILayout.Toggle("emit by distance:", ctarget.IsEmitByDistance);
            if (ctarget.IsEmitByDistance)
            {
                ctarget.DiffDistance = EditorGUILayout.FloatField("diff distance:", ctarget.DiffDistance);
            }
            else
            {
                ctarget.ChanceToEmit = EditorGUILayout.Slider("chance to emit per loop:", ctarget.ChanceToEmit, 1, 100);
                ctarget.EmitDuration = EditorGUILayout.FloatField("emit duration:", ctarget.EmitDuration);
                ctarget.EmitRate     = EditorGUILayout.FloatField("emit rate:", ctarget.EmitRate);
                ctarget.EmitLoop     = EditorGUILayout.IntField("loop count(-1 is infinite):", ctarget.EmitLoop);
                ctarget.EmitDelay    = EditorGUILayout.FloatField("delay after each loop:", ctarget.EmitDelay);
            }
            EditorGUILayout.EndVertical();
        }
    }
        void OnGUI()
        {
            if (string.IsNullOrEmpty(outputFolderPath))
            {
                outputFolderPath = Application.streamingAssetsPath;
            }
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("默认文件夹 : " + exportParams.OutputFolderPath);
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("输出文件 : ");
            EditorGUILayout.BeginHorizontal();
            {
                string relativeFilePath = GetAssetPath(outputFilePath);
                EditorGUILayout.SelectableLabel(relativeFilePath, EditorStyles.textField,
                                                GUILayout.Height(EditorGUIUtility.singleLineHeight));
                if (GUILayout.Button("浏览文件夹"))
                {
                    BrowseFile();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("模型文件: ");
                GameObject gameObject = EditorGUILayout.ObjectField(fbx, typeof(GameObject), false) as GameObject;
                if (gameObject != null && fbx != gameObject)
                {
                    fbx = gameObject;
                    GenerateSetting(gameObject);
                    if (exportParams.AnimationClips != null)
                    {
                        numberOfClips = exportParams.AnimationClips.Length;
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            exportParams.FrameRate =
                EditorGUILayout.FloatField(new GUIContent("Capture Framerate"), exportParams.FrameRate);
            exportParams.FrameRate = Mathf.Max(exportParams.FrameRate, 1.0f);
            EditorGUILayout.Space();

            exportParams.GenerateNormal =
                EditorGUILayout.Toggle(new GUIContent("GenerateNormal"), exportParams.GenerateNormal);
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Animation Count: " + numberOfClips);
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Animation Name:");
                EditorGUILayout.LabelField("Animation File:");
                EditorGUILayout.LabelField("Frames:");
            }
            EditorGUILayout.EndHorizontal();
            DrawAnimationClipsInfo();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("清除"))
                {
                    exportParams = new ExportMeshAnimationParams();
                }

                if (GUILayout.Button("导出"))
                {
                    if (exportParams == null || fbx == null)
                    {
                        return;
                    }
                    ExportMeshAnimation();
                }
            }
        }
Exemple #12
0
    public override void OnInspectorGUI()
    {
        EffectLayer ctarget = (EffectLayer)target;

        EditorGUIUtility.LookLikeControls(PreLableWidth);

        EditorGUILayout.BeginVertical();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("render type:");
        ctarget.RenderType = EditorGUILayout.Popup(ctarget.RenderType, RenderTypes);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("client transform:");
        ctarget.ClientTransform = (Transform)EditorGUILayout.ObjectField(ctarget.ClientTransform, typeof(Transform), true);
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("sync to client pos:");
        ctarget.SyncClient = EditorGUILayout.Toggle(ctarget.SyncClient);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("material :");
        ctarget.Material = (Material)EditorGUILayout.ObjectField(ctarget.Material, typeof(Material), false);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("render queue :");
        ctarget.Depth = EditorGUILayout.IntField(ctarget.Depth);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        ctarget.StartTime = EditorGUILayout.FloatField("delay(s):", ctarget.StartTime);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        ctarget.MaxFps = EditorGUILayout.FloatField("Max FPS:", ctarget.MaxFps);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        ctarget.DrawDebug = EditorGUILayout.Toggle("Draw Debug?", ctarget.DrawDebug);
        EditorGUILayout.EndVertical();

        if (ctarget.DrawDebug)
        {
            EditorGUILayout.BeginHorizontal();
            ctarget.DebugColor = EditorGUILayout.ColorField("debug color:", ctarget.DebugColor);
            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        if (ctarget.RenderType == 0)
        {
            SpriteConfig(ctarget);
        }
        else if (ctarget.RenderType == 1)
        {
            RibbonTrailConfig(ctarget);
        }
        else
        {
            ConeConfig(ctarget);
        }
        if (ctarget.RenderType == 0 || ctarget.RenderType == 2)
        {
            EditorGUILayout.Space();
            EditorGUILayout.Separator();
            RotateConfig(ctarget);
            EditorGUILayout.Space();
            EditorGUILayout.Separator();
            ScaleConfig(ctarget);
        }
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        ColorConfig(ctarget);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        UVConfig(ctarget);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        EmitterConfig(ctarget);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        OriginalVelocityConfig(ctarget);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        AffectorConfig(ctarget);
        EditorGUILayout.Space();
        EditorGUILayout.Separator();

        CollisionConfig(ctarget);

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

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
    private GUIStyle m_guiStyle = new GUIStyle();     //For smaller text

    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        m_guiStyle.fontSize = 9;
        //Reference to the CustomParticleSystem
        CustomParticleSystem myTarget = (CustomParticleSystem)target;

        //General options
        myTarget.p_EmitterType = (CustomParticleSystem.EmitterType)EditorGUILayout.EnumPopup("Particle System", myTarget.p_EmitterType);
        Show(serializedObject.FindProperty("p_ParticleReferences"));
        myFlag = myTarget.p_EmitterType;

        if (myFlag == CustomParticleSystem.EmitterType.Radial)
        {
            myTarget.p_NumberOfParticles = EditorGUILayout.IntField("Particles Per Burst", myTarget.p_NumberOfParticles);
        }
        else
        {
            myTarget.p_NumberOfParticles = EditorGUILayout.IntField("Number Of Particles", myTarget.p_NumberOfParticles);
        }


        myTarget.p_ParticleSpeed = EditorGUILayout.FloatField("Particle Speed", myTarget.p_ParticleSpeed);

        //Repeat Toggle + Value
        myTarget.p_isRepeating = EditorGUILayout.Toggle("Repeating", myTarget.p_isRepeating);
        if (myTarget.p_isRepeating)
        {
            EditorGUI.indentLevel += 1;
            myTarget.p_repeatSpeed = EditorGUILayout.FloatField("Repeat Speed", myTarget.p_repeatSpeed);
            EditorGUI.indentLevel -= 1;
            GUILayout.Space(10);
        }

        //Fade Toggle + Value
        myTarget.p_isFading = EditorGUILayout.Toggle("Fading", myTarget.p_isFading);
        if (myTarget.p_isFading)
        {
            EditorGUI.indentLevel   += 1;
            myTarget.p_fadeSpeed     = EditorGUILayout.FloatField("Fade Speed", myTarget.p_fadeSpeed);
            myTarget.p_destroyOnFade = EditorGUILayout.Toggle("Destroy On Fade?", myTarget.p_destroyOnFade);
            EditorGUI.indentLevel   -= 1;
            GUILayout.Space(10);
        }

        if (myFlag == CustomParticleSystem.EmitterType.Radial)
        {
            //Radial options
            myTarget.p_rotateTowardsVelocity = EditorGUILayout.Toggle("Rotate Towards Velocity", myTarget.p_rotateTowardsVelocity);
            myTarget.p_arcBurst = EditorGUILayout.Toggle("Arc Burst", myTarget.p_arcBurst);

            if (myTarget.p_arcBurst)
            {
                myTarget.p_burstArc = EditorGUILayout.FloatField("Burst Arc", myTarget.p_burstArc);
                myTarget.p_rotationBurstInDegrees = EditorGUILayout.FloatField("Rotation", myTarget.p_rotationBurstInDegrees);
            }
        }
        if (myFlag == CustomParticleSystem.EmitterType.Emitter)
        {
            //Emitter options
            myTarget.p_arcWidth = EditorGUILayout.FloatField("Arc Of Emission", myTarget.p_arcWidth);
            GUILayout.BeginHorizontal();
            GUILayout.Space(140);
            GUILayout.Label("Default direction is straight up on the Y Axis", m_guiStyle);
            GUILayout.EndHorizontal();
            myTarget.p_rotationInDegrees = EditorGUILayout.FloatField("Rotation Of Emission", myTarget.p_rotationInDegrees);
        }
        if (myFlag == CustomParticleSystem.EmitterType.Trail)
        {
            //Trail options
        }

        serializedObject.ApplyModifiedProperties();
    }
Exemple #14
0
            public void ShowField()
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                switch (parameterType)
                {
                case ParameterType.Bool:
                    VariableField <BoolValue>(v =>
                    {
                        v_bool = v.value;
                        EditorGUILayout.HelpBox(v_bool + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_bool = EditorGUILayout.Toggle(parameterName, v_bool));
                    break;

                case ParameterType.Byte:
                    v_byte = (byte)EditorGUILayout.IntField(parameterName, v_byte);
                    break;

                case ParameterType.Double:
                    v_double = EditorGUILayout.DoubleField(parameterName, v_double);
                    break;

                case ParameterType.Float:
                    VariableField <FloatValue>(v =>
                    {
                        v_float = v.value;
                        EditorGUILayout.HelpBox(v_float + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_float = EditorGUILayout.FloatField(parameterName, v_float));
                    break;

                case ParameterType.Int:
                    VariableField <IntValue>(v =>
                    {
                        v_int = v.value;
                        EditorGUILayout.HelpBox(v_int + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_int = EditorGUILayout.IntField(parameterName, v_int));
                    break;

                case ParameterType.Long:
                    v_long = EditorGUILayout.LongField(parameterName, v_long);
                    break;

                case ParameterType.MonoBehaviour:
                    v_monoBehaviour = (MonoBehaviour)EditorGUILayout.ObjectField(parameterName, v_monoBehaviour,
                                                                                 typeof(MonoBehaviour), true);
                    break;

                case ParameterType.Object:
                    VariableField <ObjectValue>(v =>
                    {
                        v_object = v.value;
                        EditorGUILayout.HelpBox(v_object + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_object = EditorGUILayout.ObjectField(parameterName, v_object, typeof(Object), true));
                    break;

                case ParameterType.GameObject:
                    VariableField <GameObjectValue>(v =>
                    {
                        v_gameObject = v.value;
                        EditorGUILayout.HelpBox(v_gameObject + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    },
                                                    () => v_gameObject =
                                                        (GameObject)EditorGUILayout.ObjectField(parameterName, v_gameObject,
                                                                                                typeof(GameObject), true));
                    break;

                case ParameterType.Short:
                    v_short = (short)EditorGUILayout.IntField(parameterName, v_short);
                    break;

                case ParameterType.String:
                    VariableField <StringValue>(v =>
                    {
                        v_string = v.value;
                        EditorGUILayout.HelpBox(v_string + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_string = EditorGUILayout.TextField(parameterName, v_string));
                    break;

                case ParameterType.Transform:
                    v_transform =
                        (Transform)EditorGUILayout.ObjectField(parameterName, v_transform, typeof(Transform),
                                                               true);
                    break;

                case ParameterType.Vector2:
                    VariableField <Vector2Value>(v =>
                    {
                        v_vector2 = v.value;
                        EditorGUILayout.HelpBox(v_vector2 + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_vector2 = EditorGUILayout.Vector2Field(parameterName, v_vector2));
                    break;

                case ParameterType.Vector3:
                    VariableField <Vector3Value>(v =>
                    {
                        v_vector3 = v.value;
                        EditorGUILayout.HelpBox(v_vector3 + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_vector3 = EditorGUILayout.Vector3Field(parameterName, v_vector3));
                    break;

                case ParameterType.Vector4:
                    VariableField <Vector4Value>(v =>
                    {
                        v_vector4 = v.value;
                        EditorGUILayout.HelpBox(v_vector4 + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_vector4 = EditorGUILayout.Vector4Field(parameterName, v_vector4));
                    break;
                }

                EditorGUILayout.EndVertical();
            }
        public override void OnInspectorGUI()
        {
            var asset = target as EffekseerEffectAsset;

            if (asset == null)
            {
                return;
            }

            EditorGUILayout.LabelField("Data Size", asset.efkBytes.Length.ToString() + " bytes");

            var scale = EditorGUILayout.FloatField("Scale", asset.Scale);

            scale = Math.Max(0, scale);
            if (asset.Scale != scale)
            {
                asset.Scale = scale;
                EditorUtility.SetDirty(asset);
            }

            textureVisible = EditorGUILayout.Foldout(textureVisible, "Texture Resources: " + asset.textureResources.Length);
            if (textureVisible)
            {
                EditorGUI.indentLevel++;
                foreach (var res in asset.textureResources)
                {
                    if (EffekseerTextureResource.InspectorField(res))
                    {
                        EditorUtility.SetDirty(asset);
                    }
                }
                EditorGUI.indentLevel--;
            }

            soundVisible = EditorGUILayout.Foldout(soundVisible, "Sound Resources: " + asset.soundResources.Length);
            if (soundVisible)
            {
                EditorGUI.indentLevel++;
                foreach (var res in asset.soundResources)
                {
                    if (EffekseerSoundResource.InspectorField(res))
                    {
                        EditorUtility.SetDirty(asset);
                    }
                }
                EditorGUI.indentLevel--;
            }

            modelVisible = EditorGUILayout.Foldout(modelVisible, "Model Resources: " + asset.modelResources.Length);
            if (modelVisible)
            {
                EditorGUI.indentLevel++;
                foreach (var res in asset.modelResources)
                {
                    if (EffekseerModelResource.InspectorField(res))
                    {
                        EditorUtility.SetDirty(asset);
                    }
                }
                EditorGUI.indentLevel--;
            }

            if (asset.materialResources != null)
            {
                materialVisible = EditorGUILayout.Foldout(materialVisible, "Material Resources: " + asset.materialResources.Length);
                if (materialVisible)
                {
                    EditorGUI.indentLevel++;
                    foreach (var res in asset.materialResources)
                    {
                        if (EffekseerMaterialResource.InspectorField(res))
                        {
                            EditorUtility.SetDirty(asset);
                        }
                    }
                    EditorGUI.indentLevel--;
                }
            }
        }
Exemple #16
0
        public static void PreferencesGUI()
        {
            // Load the preferences
            if (!prefsLoaded)
            {
                customValues.Clear();

                string stringValues = EditorPrefs.GetString("TimeWizardCustoms", "");
                if (!string.IsNullOrEmpty(stringValues))
                {
                    string[] c = stringValues.Split(","[0]);

                    for (int i = 0; i < c.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(c[i]))
                        {
                            string[] values          = c[i].Split("/"[0]);
                            TimeWizardCustomValue tw = new TimeWizardCustomValue()
                            {
                                name  = values[0],
                                speed = values[1]
                            };

                            customValues.Add(tw);
                        }
                    }
                }

                prefsLoaded = true;
            }

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(Resources.Load("Time-Wizard-Small") as Texture2D);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Name", GUILayout.Width(100));
            GUILayout.Label("Speed Value");
            GUILayout.EndHorizontal();

            foreach (TimeWizardCustomValue cv in customValues.ToList())
            {
                GUILayout.BeginHorizontal();
                cv.name  = GUILayout.TextField(cv.name, GUILayout.Width(100));
                cv.speed = EditorGUILayout.FloatField(float.Parse(cv.speed)).ToString();
                if (GUILayout.Button("X", GUILayout.Width(50)))
                {
                    customValues.Remove(cv);
                }
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add New Custom Value"))
            {
                TimeWizardCustomValue tw = new TimeWizardCustomValue();
                tw.name  = "New Value";
                tw.speed = "1";
                customValues.Add(tw);
            }

            // Save the preferences
            if (GUI.changed)
            {
                string saveFile = "";
                for (int i = 0; i < customValues.Count; i++)
                {
                    saveFile += customValues[i].name + "/" + customValues[i].speed.ToString() + ",";
                }
                EditorPrefs.SetString("TimeWizardCustoms", saveFile);
            }
        }
        public virtual void draw()
        {
            scenes = Controller.Instance.IdentifierSummary.getIds <IChapterTarget>();
            scenes = scenes.Except(Controller.Instance.IdentifierSummary.getIds <Cutscene>()).ToArray();

            EditorGUI.BeginChangeCheck();
            var sceneIndex = EditorGUILayout.Popup(TC.get("Element.Name2"), Array.IndexOf(scenes, effect.getTargetId()), scenes);

            if (EditorGUI.EndChangeCheck())
            {
                SetDestinyScene(sceneIndex);
            }

            if (sceneIndex == -1)
            {
                EditorGUILayout.HelpBox("TriggerSceneEffectEditor.ValidDestination".Traslate(), MessageType.Error);
                return;
            }

            // Transition Type
            EditorGUI.BeginChangeCheck();
            var newType = EditorGUILayout.Popup(TC.get("NextScene.Transition"), (int)effect.getTransitionType(), transitionTypes);

            if (EditorGUI.EndChangeCheck())
            {
                effect.setTransitionType((TransitionType)newType);
            }

            // Transition Time
            EditorGUI.BeginChangeCheck();
            var time = Mathf.Clamp(EditorGUILayout.IntField(TC.get("NextScene.TransitionTime"), effect.getTransitionTime()), 0, 5000);

            if (EditorGUI.EndChangeCheck())
            {
                effect.setTransitionTime(time);
            }

            var scenesList = Controller.Instance.SelectedChapterDataControl.getScenesList();

            // If the selected scene IS a scene (not a cutscene or any other type)
            if (Controller.Instance.PlayerMode == Controller.FILE_ADVENTURE_3RDPERSON_PLAYER && sceneIndex < scenesList.getScenes().Count)
            {
                var pos = EditorGUILayout.Vector2IntField(TC.get("Inventory.Position"), new Vector2Int(effect.getX(), effect.getY()));
                effect.setPosition(pos.x, pos.y);

                EditorGUI.BeginChangeCheck();
                bool useDestinyScale = EditorGUILayout.Toggle("TriggerSceneEffectEditor.UseScale".Traslate(), effect.DestinyScale >= 0);
                if (EditorGUI.EndChangeCheck())
                {
                    effect.DestinyScale = useDestinyScale ? 1f : float.MinValue;
                }

                if (useDestinyScale)
                {
                    EditorGUI.BeginChangeCheck();
                    var newScale = Mathf.Max(0.001f, EditorGUILayout.FloatField(TC.get("SceneLocation.Scale"), effect.DestinyScale));
                    if (EditorGUI.EndChangeCheck())
                    {
                        effect.DestinyScale = newScale;
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("TriggerSceneEffectEditor.SizeMaintained".Traslate(), MessageType.Info);
                }

                localSceneEditor.Components = EditorWindowBase.Components;
                localSceneEditor.Scene      = scenesList.getScenes()[sceneIndex];
                playerDestination.setValues(effect.getX(), effect.getY(), useDestinyScale ? effect.DestinyScale : 1f);

                var previousScale = playerDestination.getScale();

                localSceneEditor.Draw(GUILayoutUtility.GetRect(0, 200, GUILayout.ExpandWidth(true)));
                effect.setPosition(playerDestination.getX(), playerDestination.getY());
                if (previousScale != playerDestination.getScale())
                {
                    effect.DestinyScale = playerDestination.getScale();
                }
            }

            EditorGUILayout.HelpBox(TC.get("TriggerSceneEffect.Description"), MessageType.Info);
        }
Exemple #18
0
    public override void OnInspectorGUI()
    {
        if (positionProperties == null)
        {
            positionProperties = new SerializedProperty[3];

            positionProperties[0] = serializedObject.FindProperty("m_LocalPosition.x");
            positionProperties[1] = serializedObject.FindProperty("m_LocalPosition.y");
            positionProperties[2] = serializedObject.FindProperty("m_LocalPosition.z");
        }

        if (scaleProperties == null)
        {
            scaleProperties = new SerializedProperty[3];

            scaleProperties[0] = serializedObject.FindProperty("m_LocalScale.x");
            scaleProperties[1] = serializedObject.FindProperty("m_LocalScale.y");
            scaleProperties[2] = serializedObject.FindProperty("m_LocalScale.z");
        }

        EditorGUIUtility.labelWidth = 15.0f;
        EditorGUIUtility.fieldWidth = 0.0f;

        serializedObject.Update();

        EditorGUI.BeginChangeCheck();

        GUIContent resetToZeroText = new GUIContent("0", "Set all elements to 0.");
        GUIContent resetToOneText  = new GUIContent("1", "Set all elements to 1.");
        GUIContent positionText    = new GUIContent("Position", "The local position of the transform.");
        GUIContent rotationText    = new GUIContent("Rotation", "The local euler angles rotation of the transform.");
        GUIContent scaleText       = new GUIContent("Scale", "The local scale of the transform.");

        GUIContent[] directionLabels = new GUIContent[3];
        directionLabels[0] = new GUIContent("X");
        directionLabels[1] = new GUIContent("Y");
        directionLabels[2] = new GUIContent("Z");

        // handle position
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button(resetToZeroText, new GUILayoutOption[] { GUILayout.MaxWidth(21.0f), GUILayout.MaxHeight(15.0f) }))
        {
            foreach (Object obj in targets)
            {
                Undo.RecordObject(obj, "Undo transform position change");

                Transform t = obj as Transform;
                t.localPosition = Vector3.zero;
            }

            for (int i = 0; i < positionProperties.Length; ++i)
            {
                positionProperties[i].floatValue = 0.0f;
            }
        }

        EditorGUILayout.LabelField(positionText);

        for (int i = 0; i < positionProperties.Length; ++i)
        {
            EditorGUI.BeginChangeCheck();

            EditorGUI.showMixedValue = positionProperties[i].hasMultipleDifferentValues;

            float newValue = EditorGUILayout.FloatField(directionLabels[i], positionProperties[i].floatValue, GUILayout.MinWidth(20.0f));

            if (EditorGUI.EndChangeCheck())
            {
                foreach (Object obj in targets)
                {
                    Undo.RecordObject(obj, "Undo transform position change");

                    Transform t = obj as Transform;

                    Vector3 newPos = t.localPosition;

                    if (i == 0)
                    {
                        newPos.x = newValue;
                    }
                    else if (i == 1)
                    {
                        newPos.y = newValue;
                    }
                    else
                    {
                        newPos.z = newValue;
                    }

                    t.localPosition = newPos;
                }
                positionProperties[i].floatValue = newValue;
            }
        }
        EditorGUILayout.EndHorizontal();


        // handle rotation.  unfortunately, Unity stores it as a quaternion, but we want to display it in Euler angles,
        // so we have to go about it in a more convoluted way than the position and scale
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button(resetToZeroText, new GUILayoutOption[] { GUILayout.MaxWidth(21.0f), GUILayout.MaxHeight(15.0f) }))
        {
            foreach (Object obj in targets)
            {
                Undo.RecordObject(obj, "Undo transform rotation change");

                (obj as Transform).localRotation = Quaternion.identity;
            }
        }

        EditorGUILayout.LabelField(rotationText);

        bool[]  changes        = new bool[] { false, false, false };
        float[] rotationValues = new float[] { (target as Transform).localEulerAngles.x, (target as Transform).localEulerAngles.y, (target as Transform).localEulerAngles.z };

        for (int i = 1; i < targets.Length; ++i)
        {
            Transform previous = targets[i - 1] as Transform;
            Transform current  = targets[i] as Transform;

            if (previous.localEulerAngles.x != current.localEulerAngles.x)
            {
                changes[0] = true;
            }
            if (previous.localEulerAngles.y != current.localEulerAngles.y)
            {
                changes[1] = true;
            }
            if (previous.localEulerAngles.z != current.localEulerAngles.z)
            {
                changes[2] = true;
            }
        }

        for (int i = 0; i < 3; ++i)
        {
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = changes[i];
            rotationValues[i]        = EditorGUILayout.FloatField(directionLabels[i], rotationValues[i], GUILayout.MinWidth(20.0f));

            if (EditorGUI.EndChangeCheck())
            {
                foreach (Object obj in targets)
                {
                    Undo.RecordObject(obj, "Undo transform rotation change");

                    Transform t   = obj as Transform;
                    Vector3   rot = t.localEulerAngles;

                    if (i == 0)
                    {
                        rot.x = rotationValues[i];
                    }
                    if (i == 1)
                    {
                        rot.y = rotationValues[i];
                    }
                    if (i == 2)
                    {
                        rot.z = rotationValues[i];
                    }

                    t.localEulerAngles = rot;
                }
            }
        }

        EditorGUILayout.EndHorizontal();


        // handle scale
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button(resetToOneText, new GUILayoutOption[] { GUILayout.MaxWidth(21.0f), GUILayout.MaxHeight(15.0f) }))
        {
            foreach (Object obj in targets)
            {
                Undo.RecordObject(obj, "Undo transform scale change");

                Transform t = obj as Transform;
                t.localScale = Vector3.one;
            }

            for (int i = 0; i < scaleProperties.Length; ++i)
            {
                scaleProperties[i].floatValue = 1.0f;
            }
        }

        if (GUILayout.Button(resetToZeroText, new GUILayoutOption[] { GUILayout.MaxWidth(21.0f), GUILayout.MaxHeight(15.0f) }))
        {
            foreach (Object obj in targets)
            {
                Undo.RecordObject(obj, "Undo transform scale change to 0");

                Transform t = obj as Transform;
                t.localScale = Vector3.one;
            }

            for (int i = 0; i < scaleProperties.Length; ++i)
            {
                scaleProperties[i].floatValue = 0.0f;
            }
        }

        EditorGUILayout.LabelField(scaleText);

        for (int i = 0; i < scaleProperties.Length; ++i)
        {
            EditorGUI.BeginChangeCheck();

            EditorGUI.showMixedValue = scaleProperties[i].hasMultipleDifferentValues;

            float newValue = EditorGUILayout.FloatField(directionLabels[i], scaleProperties[i].floatValue, GUILayout.MinWidth(20.0f));

            if (EditorGUI.EndChangeCheck())
            {
                foreach (Object obj in targets)
                {
                    Undo.RecordObject(obj, "Undo transform scale change");

                    Transform t = obj as Transform;

                    Vector3 newScale = t.localScale;

                    if (i == 0)
                    {
                        newScale.x = newValue;
                    }
                    else if (i == 1)
                    {
                        newScale.y = newValue;
                    }
                    else
                    {
                        newScale.z = newValue;
                    }

                    t.localScale = newScale;
                }
                scaleProperties[i].floatValue = newValue;
            }
        }

        EditorGUILayout.EndHorizontal();

        EditorGUI.showMixedValue = false;

        serializedObject.ApplyModifiedProperties();
    }
        /*
         * static void OnGUIContentsMaterialInspector(Material material, bool mixedValues)
         * {
         *      //if (materialEditor == null || prevMaterial != material)
         *      {
         *              var editor = materialEditor as Editor;
         *              Editor.CreateCachedEditor(material, typeof(MaterialEditor), ref editor);
         *              materialEditor = editor as MaterialEditor;
         *      }
         *
         *      if (materialEditor != null)
         *      {
         *              EditorGUI.showMixedValue = mixedValues;
         *              try
         *              {
         *                      materialEditor.DrawHeader();
         *                      if (materialEditor.PropertiesGUI())
         *                      {
         *                              materialEditor.PropertiesChanged();
         *                      }
         *              }
         *              catch
         *              {}
         *              EditorGUI.showMixedValue = false;
         *      }
         * }
         */

        private static void OnGUIContents(bool isSceneGUI, EditModeSurface tool)
        {
            EditModeCommonGUI.StartToolGUI();

            var selectedBrushSurfaces = (tool == null) ? new SelectedBrushSurface[0] : tool.GetSelectedSurfaces();
            var enabled = selectedBrushSurfaces.Length > 0;

            EditorGUI.BeginDisabledGroup(!enabled);
            {
                Material material      = null;
                var      currentTexGen = new TexGen();

                var  haveTexgen            = false;
                var  multipleColors        = !enabled;
                var  multipleTranslationX  = !enabled;
                var  multipleTranslationY  = !enabled;
                var  multipleScaleX        = !enabled;
                var  multipleScaleY        = !enabled;
                var  multipleRotationAngle = !enabled;
                var  multipleMaterials     = !enabled;
                bool?textureLocked         = null;

                bool foundHelperMaterial = false;
                RenderSurfaceType?firstRenderSurfaceType = null;
                Material          firstMaterial          = null;
                if (selectedBrushSurfaces.Length > 0)
                {
                    for (var i = 0; i < selectedBrushSurfaces.Length; i++)
                    {
                        var brush = selectedBrushSurfaces[i].brush;
                        if (!brush)
                        {
                            continue;
                        }
                        var surfaceIndex = selectedBrushSurfaces[i].surfaceIndex;
                        if (surfaceIndex >= brush.Shape.Surfaces.Length)
                        {
                            Debug.LogWarning("surface_index >= brush.Shape.Surfaces.Length");
                            continue;
                        }
                        var texGenIndex = brush.Shape.Surfaces[surfaceIndex].TexGenIndex;
                        if (texGenIndex >= brush.Shape.TexGens.Length)
                        {
                            Debug.LogWarning("texGen_index >= brush.Shape.TexGens.Length");
                            continue;
                        }
                        var      brushCache = InternalCSGModelManager.GetBrushCache(brush);
                        var      model      = (brushCache != null) ? brushCache.childData.Model : null;
                        Material foundMaterial;
                        var      texGenFlags = brush.Shape.TexGenFlags[texGenIndex];
                        if (model && (!model.IsRenderable || model.ShadowsOnly))
                        {
                            foundHelperMaterial = true;
                            if (!firstRenderSurfaceType.HasValue)
                            {
                                firstRenderSurfaceType = ModelTraits.GetModelSurfaceType(model);
                            }
                            foundMaterial = null;
                        }
                        else
                        if ((texGenFlags & TexGenFlags.NoRender) == TexGenFlags.NoRender)
                        {
                            foundHelperMaterial = true;
                            if (!firstRenderSurfaceType.HasValue)
                            {
                                if ((texGenFlags & TexGenFlags.NoCastShadows) != TexGenFlags.NoCastShadows)
                                {
                                    firstRenderSurfaceType = RenderSurfaceType.ShadowOnly;
                                }
                                else
                                if ((texGenFlags & TexGenFlags.NoCollision) != TexGenFlags.NoCollision)
                                {
                                    firstRenderSurfaceType = RenderSurfaceType.Collider;
                                }
                                else
                                {
                                    firstRenderSurfaceType = RenderSurfaceType.Hidden;
                                }
                            }
                            foundMaterial = null;
                        }
                        else
                        {
                            var surfaceMaterial = brush.Shape.TexGens[texGenIndex].RenderMaterial;
                            if (!foundHelperMaterial)
                            {
                                var surfaceType = MaterialUtility.GetMaterialSurfaceType(surfaceMaterial);
                                if (!firstRenderSurfaceType.HasValue)
                                {
                                    firstRenderSurfaceType = surfaceType;
                                }
                                foundHelperMaterial = surfaceType != RenderSurfaceType.Normal;
                            }
                            foundMaterial = surfaceMaterial;
                        }
                        if ((texGenFlags & TexGenFlags.WorldSpaceTexture) == TexGenFlags.WorldSpaceTexture)
                        {
                            if (i == 0)
                            {
                                textureLocked = false;
                            }
                            else if (textureLocked.HasValue && textureLocked.Value)
                            {
                                textureLocked = null;
                            }
                        }
                        else
                        {
                            if (i == 0)
                            {
                                textureLocked = true;
                            }
                            else if (textureLocked.HasValue && !textureLocked.Value)
                            {
                                textureLocked = null;
                            }
                        }
                        if (foundMaterial != material)
                        {
                            if (!material)
                            {
                                firstMaterial = foundMaterial;
                                material      = foundMaterial;
                            }
                            else
                            {
                                multipleMaterials = true;
                            }
                        }
                        if (!haveTexgen)
                        {
                            currentTexGen = brush.Shape.TexGens[texGenIndex];
                            haveTexgen    = true;
                        }
                        else
                        {
                            if (!multipleColors)
                            {
                                var color = brush.Shape.TexGens[texGenIndex].Color;
                                multipleColors = currentTexGen.Color.a != color.a ||
                                                 currentTexGen.Color.b != color.b ||
                                                 currentTexGen.Color.g != color.g ||
                                                 currentTexGen.Color.r != color.r;
                            }
                            if (!multipleScaleX || !multipleScaleY)
                            {
                                var scale = brush.Shape.TexGens[texGenIndex].Scale;
                                multipleScaleX = multipleScaleX || currentTexGen.Scale.x != scale.x;
                                multipleScaleY = multipleScaleY || currentTexGen.Scale.y != scale.y;
                            }

                            if (!multipleTranslationX || !multipleTranslationY)
                            {
                                var translation = brush.Shape.TexGens[texGenIndex].Translation;
                                multipleTranslationX = multipleTranslationX || currentTexGen.Translation.x != translation.x;
                                multipleTranslationY = multipleTranslationY || currentTexGen.Translation.y != translation.y;
                            }

                            if (!multipleRotationAngle)
                            {
                                var rotationAngle = brush.Shape.TexGens[texGenIndex].RotationAngle;
                                multipleRotationAngle = currentTexGen.RotationAngle != rotationAngle;
                            }
                        }
                    }
                    if (foundHelperMaterial && !firstMaterial)
                    {
                        if (firstRenderSurfaceType.HasValue)
                        {
                            firstMaterial = MaterialUtility.GetSurfaceMaterial(firstRenderSurfaceType.Value);
                        }
                        else
                        {
                            firstMaterial = MaterialUtility.HiddenMaterial;
                        }
                    }
                }

                GUILayout.BeginVertical(isSceneGUI ? materialDoubleWidth : CSG_GUIStyleUtility.ContentEmpty);
                {
                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        /*
                         * Color new_color;
                         * EditorGUI.BeginChangeCheck();
                         * {
                         *      EditorGUI.showMixedValue = multipleColors;
                         *      // why doesn't the colorfield return a modified color?
                         *      try
                         *      {
                         *              new_color = EditorGUILayout.ColorField(GUIContent.none, currentTexGen.Color);
                         *      }
                         *      catch
                         *      {
                         *              new_color = currentTexGen.Color;
                         *      }
                         * }
                         * if (EditorGUI.EndChangeCheck() || currentTexGen.Color != new_color)
                         * {
                         *      SurfaceUtility.SetColors(selectedBrushSurfaces, new_color);
                         * }
                         */
                        if (isSceneGUI)
                        {
                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                EditorGUI.BeginDisabledGroup(material == null);
                                {
                                    GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
                                    {
                                        GUILayout.Space(1);

                                        /*
                                         * Color new_color;
                                         * EditorGUI.BeginChangeCheck();
                                         * {
                                         *      EditorGUI.showMixedValue = multipleColors;
                                         *      // why doesn't the colorfield return a modified color?
                                         *      try
                                         *      {
                                         *              new_color = EditorGUILayout.ColorField(GUIContent.none, currentTexGen.Color);
                                         *      }
                                         *      catch
                                         *      {
                                         *              new_color = currentTexGen.Color;
                                         *      }
                                         * }
                                         * if (EditorGUI.EndChangeCheck() || currentTexGen.Color != new_color)
                                         * {
                                         *      SurfaceUtility.SetColors(selectedBrushSurfaces, new_color);
                                         * }
                                         *
                                         * GUILayout.Space(1);
                                         */
                                        Material newMaterial;
                                        EditorGUI.BeginChangeCheck();
                                        {
                                            EditorGUI.showMixedValue = multipleMaterials;
                                            newMaterial = EditorGUILayout.ObjectField(material, typeof(Material), true) as Material;
                                            EditorGUI.showMixedValue = false;
                                        }
                                        if (EditorGUI.EndChangeCheck())
                                        {
                                            if (newMaterial)
                                            {
                                                SurfaceUtility.SetMaterials(selectedBrushSurfaces, newMaterial);
                                                CSGSettings.DefaultMaterial = newMaterial;
                                                CSGSettings.Save();
                                            }
                                        }
                                    }
                                    GUILayout.EndVertical();
                                    GUILayout.Space(1);
                                }
                                EditorGUI.EndDisabledGroup();
                            }
                            GUILayout.EndHorizontal();
                            GUILayout.Space(4);
                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                GUILayout.Space(2);
                                OnGUIContentsMaterialImage(isSceneGUI, firstMaterial, multipleMaterials, selectedBrushSurfaces);
                                GUILayout.BeginHorizontal(materialWidth);
                                {
                                    GUILayout.FlexibleSpace();
                                    GUILayout.BeginVertical(materialHeight);
                                    {
                                        OnGUIContentsJustify(isSceneGUI, selectedBrushSurfaces);
                                        GUILayout.FlexibleSpace();
                                    }
                                    GUILayout.EndVertical();
                                }
                                GUILayout.EndHorizontal();
                                GUILayout.FlexibleSpace();
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    GUILayout.EndVertical();

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                    }

                    if (currentTexGen.Scale.x == 0.0f)
                    {
                        currentTexGen.Scale.x = 1.0f;
                    }
                    if (currentTexGen.Scale.y == 0.0f)
                    {
                        currentTexGen.Scale.y = 1.0f;
                    }

                    const float scale_round = 10000.0f;
                    currentTexGen.Scale.x       = Mathf.RoundToInt(currentTexGen.Scale.x * scale_round) / scale_round;
                    currentTexGen.Scale.y       = Mathf.RoundToInt(currentTexGen.Scale.y * scale_round) / scale_round;
                    currentTexGen.Translation.x = Mathf.RoundToInt(currentTexGen.Translation.x * scale_round) / scale_round;
                    currentTexGen.Translation.y = Mathf.RoundToInt(currentTexGen.Translation.y * scale_round) / scale_round;
                    currentTexGen.RotationAngle = Mathf.RoundToInt(currentTexGen.RotationAngle * scale_round) / scale_round;

                    var leftStyle   = isSceneGUI ? EditorStyles.miniButtonLeft  : GUI.skin.button;
                    var middleStyle = isSceneGUI ? EditorStyles.miniButtonMid   : GUI.skin.button;
                    var rightStyle  = isSceneGUI ? EditorStyles.miniButtonRight : GUI.skin.button;

                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        EditorGUI.BeginChangeCheck();
                        {
                            EditorGUI.showMixedValue = !textureLocked.HasValue;
                            textureLocked            = EditorGUILayout.ToggleLeft(ContentLockTexture, textureLocked.HasValue ? textureLocked.Value : false);
                            TooltipUtility.SetToolTip(ToolTipLockTexture);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            SurfaceUtility.SetTextureLock(selectedBrushSurfaces, textureLocked.Value);
                        }
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (isSceneGUI)
                            {
                                EditorGUILayout.LabelField(ContentUVScale, EditorStyles.miniLabel, labelWidth);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(ContentUVScale, largeLabelWidth);
                            }
                            TooltipUtility.SetToolTip(ToolTipScaleUV);

                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                if (!isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentUSymbol, unitWidth);
                                }
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue = multipleScaleX;
                                    currentTexGen.Scale.x    = EditorGUILayout.FloatField(currentTexGen.Scale.x, minFloatFieldWidth);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetScaleX(selectedBrushSurfaces, currentTexGen.Scale.x);
                                }
                                if (!isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentVSymbol, unitWidth);
                                }
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue = multipleScaleY;
                                    currentTexGen.Scale.y    = EditorGUILayout.FloatField(currentTexGen.Scale.y, minFloatFieldWidth);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetScaleY(selectedBrushSurfaces, currentTexGen.Scale.y);
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (isSceneGUI)
                            {
                                EditorGUILayout.LabelField(ContentOffset, EditorStyles.miniLabel, labelWidth);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(ContentOffset, largeLabelWidth);
                            }
                            TooltipUtility.SetToolTip(ToolTipOffsetUV);

                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                if (!isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentUSymbol, unitWidth);
                                }
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue    = multipleTranslationX;
                                    currentTexGen.Translation.x = EditorGUILayout.FloatField(currentTexGen.Translation.x, minFloatFieldWidth);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetTranslationX(selectedBrushSurfaces, currentTexGen.Translation.x);
                                }

                                if (!isSceneGUI)
                                {
                                    EditorGUILayout.LabelField(ContentVSymbol, unitWidth);
                                }
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue    = multipleTranslationY;
                                    currentTexGen.Translation.y = EditorGUILayout.FloatField(currentTexGen.Translation.y, minFloatFieldWidth);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetTranslationY(selectedBrushSurfaces, currentTexGen.Translation.y);
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (isSceneGUI)
                            {
                                EditorGUILayout.LabelField(ContentRotate, EditorStyles.miniLabel, labelWidth);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(ContentRotate, largeLabelWidth);
                            }
                            TooltipUtility.SetToolTip(ToolTipRotation);

                            if (!isSceneGUI)
                            {
                                GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
                            }

                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue    = multipleRotationAngle;
                                    currentTexGen.RotationAngle = EditorGUILayout.FloatField(currentTexGen.RotationAngle, minFloatFieldWidth);
                                    if (!isSceneGUI)
                                    {
                                        EditorGUILayout.LabelField(ContentAngleSymbol, unitWidth);
                                    }
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    SurfaceUtility.SetRotationAngle(selectedBrushSurfaces, currentTexGen.RotationAngle);
                                }
                            }
                            GUILayout.EndHorizontal();

                            var buttonWidth = isSceneGUI ? new GUILayoutOption[] { angleButtonWidth } : new GUILayoutOption[0];
                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                if (GUILayout.Button(ContentRotate90Negative, leftStyle, buttonWidth))
                                {
                                    SurfaceUtility.AddRotationAngle(selectedBrushSurfaces, -90.0f);
                                }
                                TooltipUtility.SetToolTip(ToolTipRotate90Negative);
                                if (GUILayout.Button(ContentRotate90Positive, rightStyle, buttonWidth))
                                {
                                    SurfaceUtility.AddRotationAngle(selectedBrushSurfaces, +90.0f);
                                }
                                TooltipUtility.SetToolTip(ToolTipRotate90Positive);
                            }
                            GUILayout.EndHorizontal();
                            if (!isSceneGUI)
                            {
                                GUILayout.EndVertical();
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                    }

                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (!isSceneGUI)
                            {
                                GUILayout.Label(ContentFit, largeLabelWidth);
                            }
                            else
                            {
                                GUILayout.Label(ContentFit, EditorStyles.miniLabel, smallLabelWidth);
                            }
                            if (GUILayout.Button(ContentFitX, leftStyle))
                            {
                                SurfaceUtility.FitSurfaceX(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFitX);
                            if (GUILayout.Button(ContentFitXY, middleStyle))
                            {
                                SurfaceUtility.FitSurface(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFitXY);
                            if (GUILayout.Button(ContentFitY, rightStyle))
                            {
                                SurfaceUtility.FitSurfaceY(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFitY);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (!isSceneGUI)
                            {
                                GUILayout.Label(ContentReset, largeLabelWidth);
                            }
                            else
                            {
                                GUILayout.Label(ContentReset, EditorStyles.miniLabel, smallLabelWidth);
                            }
                            if (GUILayout.Button(ContentResetX, leftStyle))
                            {
                                SurfaceUtility.ResetSurfaceX(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipResetX);
                            if (GUILayout.Button(ContentResetXY, middleStyle))
                            {
                                SurfaceUtility.ResetSurface(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipResetXY);
                            if (GUILayout.Button(ContentResetY, rightStyle))
                            {
                                SurfaceUtility.ResetSurfaceY(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipResetY);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (!isSceneGUI)
                            {
                                GUILayout.Label(ContentFlip, largeLabelWidth);
                            }
                            else
                            {
                                GUILayout.Label(ContentFlip, EditorStyles.miniLabel, smallLabelWidth);
                            }
                            if (GUILayout.Button(ContentFlipX, leftStyle))
                            {
                                SurfaceUtility.FlipX(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFlipX);
                            if (GUILayout.Button(ContentFlipXY, middleStyle))
                            {
                                SurfaceUtility.FlipXY(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFlipXY);
                            if (GUILayout.Button(ContentFlipY, rightStyle))
                            {
                                SurfaceUtility.FlipY(selectedBrushSurfaces);
                            }
                            TooltipUtility.SetToolTip(ToolTipFlipY);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            if (!isSceneGUI)
                            {
                                GUILayout.Label(ContentScale, largeLabelWidth);
                            }
                            else
                            {
                                GUILayout.Label(ContentScale, EditorStyles.miniLabel, smallLabelWidth);
                            }
                            if (GUILayout.Button(ContentDoubleScale, leftStyle))
                            {
                                SurfaceUtility.MultiplyScale(selectedBrushSurfaces, 2.0f);
                            }
                            TooltipUtility.SetToolTip(ToolTipDoubleScale);
                            if (GUILayout.Button(ContentHalfScale, rightStyle))
                            {
                                SurfaceUtility.MultiplyScale(selectedBrushSurfaces, 0.5f);
                            }
                            TooltipUtility.SetToolTip(ToolTipHalfScale);
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                    }

                    if (!isSceneGUI)
                    {
                        OnGUIContentsJustify(isSceneGUI, selectedBrushSurfaces);
                    }

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                    }

                    GUILayout.BeginVertical(isSceneGUI ? GUI.skin.box : GUIStyle.none);
                    {
                        EditModeCommonGUI.OnSurfaceFlagButtons(selectedBrushSurfaces, isSceneGUI);
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            EditorGUI.BeginDisabledGroup(!SurfaceUtility.CanSmooth(selectedBrushSurfaces));
                            {
                                if (GUILayout.Button(ContentSmoothSurfaces, leftStyle))
                                {
                                    SurfaceUtility.Smooth(selectedBrushSurfaces);
                                }
                                TooltipUtility.SetToolTip(ToolTipSmoothSurfaces);
                            }
                            EditorGUI.EndDisabledGroup();
                            EditorGUI.BeginDisabledGroup(!SurfaceUtility.CanUnSmooth(selectedBrushSurfaces));
                            {
                                if (GUILayout.Button(ContentUnSmoothSurfaces, rightStyle))
                                {
                                    SurfaceUtility.UnSmooth(selectedBrushSurfaces);
                                }
                                TooltipUtility.SetToolTip(ToolTipUnSmoothSurfaces);
                            }
                            EditorGUI.EndDisabledGroup();
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndVertical();

                    if (!isSceneGUI)
                    {
                        EditorGUILayout.Space();
                        Material new_material;
                        GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                        {
                            EditorGUILayout.LabelField(ContentMaterial, largeLabelWidth);
                            GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                EditorGUI.BeginChangeCheck();
                                {
                                    EditorGUI.showMixedValue = multipleMaterials;
                                    new_material             = EditorGUILayout.ObjectField(material, typeof(Material), true) as Material;
                                    EditorGUI.showMixedValue = false;
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    if (!new_material)
                                    {
                                        new_material = MaterialUtility.MissingMaterial;
                                    }
                                    SurfaceUtility.SetMaterials(selectedBrushSurfaces, new_material);
                                }
                            }
                            GUILayout.Space(2);
                            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                            {
                                GUILayout.Space(5);
                                OnGUIContentsMaterialImage(isSceneGUI, firstMaterial, multipleMaterials, selectedBrushSurfaces);
                            }
                            GUILayout.EndHorizontal();
                            GUILayout.EndVertical();
                        }
                        GUILayout.EndHorizontal();
                        // Unity won't let us do this
                        //GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
                        //OnGUIContentsMaterialInspector(first_material, multiple_materials);
                        //GUILayout.EndVertical();
                    }
                }
                GUILayout.EndVertical();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUI.showMixedValue = false;
        }
Exemple #20
0
    public override void OnInspectorGUI()
    {
        worldmanagerobject.Update();
        EditorGUILayout.BeginVertical();
        int i = 0;

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Pool Amount -");
        worldmanager.PoolAmount = EditorGUILayout.IntField(worldmanager.PoolAmount);
        EditorGUILayout.EndHorizontal();
        if (worldmanager.Worlds.Count > 0)
        {
            worldmanager.startWorld = EditorGUILayout.IntSlider("Start World ", worldmanager.startWorld, 0, worldmanager.Worlds.Count - 1);
        }
        worldmanager.StartTarget = (Transform)EditorGUILayout.ObjectField("Player Start Look Target", worldmanager.StartTarget, typeof(Transform), true);
        foreach (World w in worldmanager.Worlds)
        {
            worldmanager.showWorld[i] = EditorGUILayout.Foldout(worldmanager.showWorld[i], "World " + i);
            if (worldmanager.showWorld[i])
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("World Probability -");

                w.probability = EditorGUILayout.Slider(w.probability, 0, 1);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Max Track Length");
                w.maxTracklength = EditorGUILayout.IntSlider(w.maxTracklength, w.minTracklength, 50);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Min Track Length");
                w.minTracklength = EditorGUILayout.IntSlider(w.minTracklength, 2, 10);
                EditorGUILayout.EndHorizontal();
                string[] minStrings = { "Zero", "Value" };
                int[]    minInts    = { 0, 1 };

                w.list1 = EditorGUILayout.IntPopup("Appears after Distance", w.list1, minStrings, minInts);

                if (w.list1 == 1)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space();
                    w.minAppearLimit = EditorGUILayout.FloatField(w.minAppearLimit);
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    w.minAppearLimit = 0f;
                }
                string[] maxStrings = { "Infinity", "Value" };
                int[]    maxInts    = { 0, 1 };

                w.list2 = EditorGUILayout.IntPopup("Doesn't Appear after Distance", w.list2, maxStrings, maxInts);

                if (w.list2 == 1)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space();
                    w.maxAppearLimit = EditorGUILayout.FloatField(w.maxAppearLimit);
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    w.maxAppearLimit = -1f;
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("Remove World"))
                {
                    worldmanager.Worlds.RemoveAt(i);

                    worldmanager.showWorld.RemoveAt(i);
                    break;
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("Add new Track"))
                {
                    w.tracks.Add(new Tracks());
                    w.showTrack.Add(false);
                }

                int j = 0;
                EditorGUILayout.BeginVertical();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                foreach (Tracks t in w.tracks)
                {
                    w.showTrack[j] = EditorGUILayout.Foldout(w.showTrack[j], "Track " + j);
                    if (w.showTrack[j])
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label("Track Probability ");
                        t.probability = EditorGUILayout.Slider(t.probability, 0, 1);
                        EditorGUILayout.EndHorizontal();

                        t.track = (GameObject)EditorGUILayout.ObjectField("Track", t.track, typeof(GameObject), true);
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.Space();
                        if (GUILayout.Button("Remove Track"))
                        {
                            worldmanager.Worlds[i].tracks.RemoveAt(j);

                            worldmanager.Worlds[i].showTrack.RemoveAt(j);
                            break;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    ++j;
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndHorizontal();
            }
            ++i;
        }

        EditorGUILayout.EndVertical();
        if (GUILayout.Button("Add new World"))
        {
            worldmanager.Worlds.Add(new World());
            worldmanager.showWorld.Add(false);
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
            EditorUtility.SetDirty(worldmanager);
            #if !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
            EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
        }

        worldmanagerobject.ApplyModifiedProperties();
    }
    void PathFollowingType()
    {
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(windw.Follower.FindPropertyRelative("PathFollowingType"));
        if (EditorGUI.EndChangeCheck())
        {
            windw.Follower.serializedObject.ApplyModifiedProperties();

            SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData);
        }

        if (windw.Follower.FindPropertyRelative("PathFollowingType").intValue == 1)
        {
            EditorGUI.BeginChangeCheck();
            var groundRayRadius = EditorGUILayout.FloatField("Ground Ray Length", windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("GroundRayLength").floatValue);
            if (EditorGUI.EndChangeCheck())
            {
                windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("GroundRayLength").floatValue = groundRayRadius;
                windw.Follower.serializedObject.ApplyModifiedProperties();

                SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData);
            }

            EditorGUI.BeginChangeCheck();
            var obstacleRayRadius = EditorGUILayout.FloatField("Obstacle Ray Length", windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("ObstacleRayLength").floatValue);
            if (EditorGUI.EndChangeCheck())
            {
                windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("ObstacleRayLength").floatValue = obstacleRayRadius;
                windw.Follower.serializedObject.ApplyModifiedProperties();

                SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData);
            }


            EditorGUI.BeginChangeCheck();
            var offset = EditorGUILayout.FloatField("Follower ground offset", windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("FollowerGroundOffset").floatValue);
            if (EditorGUI.EndChangeCheck())
            {
                windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("FollowerGroundOffset").floatValue = offset;
                windw.Follower.serializedObject.ApplyModifiedProperties();

                SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData);
            }

            EditorGUI.BeginChangeCheck();
            var height = EditorGUILayout.FloatField("Obstacle ray height", windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("ObstacleRayHeight").floatValue);
            if (EditorGUI.EndChangeCheck())
            {
                windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("ObstacleRayHeight").floatValue = height;
                windw.Follower.serializedObject.ApplyModifiedProperties();

                SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData);
            }
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(4);

            var followGroundNormalContent = (windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("FollowGroundNormal").boolValue) ? SplinePlusEditor.On : SplinePlusEditor.Off;

            if (GUILayout.Button(followGroundNormalContent, GUIStyle.none, GUILayout.MaxWidth(40), GUILayout.MaxHeight(20)))
            {
                windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("FollowGroundNormal").boolValue =
                    !windw.Follower.FindPropertyRelative("FollowerProjection").FindPropertyRelative("FollowGroundNormal").boolValue;
                windw.Follower.serializedObject.ApplyModifiedProperties();

                SPData.SplinePlus.SplineCreationClass.UpdateAllBranches(SPData);
            }
            EditorGUILayout.LabelField("Follow ground normal");

            EditorGUILayout.EndHorizontal();
        }
    }
        public override void OnInspectorGUI()
        {
            var begin       = serializedObject.FindProperty("PlayEvent");
            var end         = serializedObject.FindProperty("StopEvent");
            var tag         = serializedObject.FindProperty("CollisionTag");
            var ev          = serializedObject.FindProperty("Event");
            var param       = serializedObject.FindProperty("Params");
            var fadeout     = serializedObject.FindProperty("AllowFadeout");
            var once        = serializedObject.FindProperty("TriggerOnce");
            var preload     = serializedObject.FindProperty("Preload");
            var overrideAtt = serializedObject.FindProperty("OverrideAttenuation");
            var minDistance = serializedObject.FindProperty("OverrideMinDistance");
            var maxDistance = serializedObject.FindProperty("OverrideMaxDistance");

            EditorGUILayout.PropertyField(begin, new GUIContent("Play Event"));
            EditorGUILayout.PropertyField(end, new GUIContent("Stop Event"));

            if (begin.enumValueIndex == 3 || begin.enumValueIndex == 4 ||
                end.enumValueIndex == 3 || end.enumValueIndex == 4)
            {
                tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue);
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(ev, new GUIContent("Event"));

            EditorEventRef editorEvent = EventManager.EventFromPath(ev.stringValue);

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtils.UpdateParamsOnEmitter(serializedObject, ev.stringValue);
                if (editorEvent != null)
                {
                    overrideAtt.boolValue  = false;
                    minDistance.floatValue = editorEvent.MinDistance;
                    maxDistance.floatValue = editorEvent.MaxDistance;
                }
            }

            // Attenuation
            {
                EditorGUI.BeginDisabledGroup(editorEvent == null || !editorEvent.Is3D);
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Override Attenuation");
                EditorGUI.BeginChangeCheck();
                overrideAtt.boolValue = EditorGUILayout.Toggle(overrideAtt.boolValue, GUILayout.Width(20));
                if (EditorGUI.EndChangeCheck() ||
                    (minDistance.floatValue == -1 && maxDistance.floatValue == -1) // never been initialiased
                    )
                {
                    minDistance.floatValue = editorEvent.MinDistance;
                    maxDistance.floatValue = editorEvent.MaxDistance;
                }
                EditorGUI.BeginDisabledGroup(!overrideAtt.boolValue);
                EditorGUIUtility.labelWidth = 30;
                minDistance.floatValue      = EditorGUILayout.FloatField("Min", minDistance.floatValue);
                minDistance.floatValue      = Mathf.Clamp(minDistance.floatValue, 0, maxDistance.floatValue);
                maxDistance.floatValue      = EditorGUILayout.FloatField("Max", maxDistance.floatValue);
                maxDistance.floatValue      = Mathf.Max(minDistance.floatValue, maxDistance.floatValue);
                EditorGUIUtility.labelWidth = 0;
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();
                EditorGUI.EndDisabledGroup();
            }

            param.isExpanded = EditorGUILayout.Foldout(param.isExpanded, "Initial Parameter Values");
            if (ev.hasMultipleDifferentValues)
            {
                if (param.isExpanded)
                {
                    GUILayout.Box("Cannot change parameters when different events are selected", GUILayout.ExpandWidth(true));
                }
            }
            else
            {
                var eventRef = EventManager.EventFromPath(ev.stringValue);
                if (param.isExpanded && eventRef != null)
                {
                    foreach (var paramRef in eventRef.Parameters)
                    {
                        bool  set;
                        float value;
                        bool  matchingSet, matchingValue;
                        CheckParameter(paramRef.Name, out set, out matchingSet, out value, out matchingValue);

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PrefixLabel(paramRef.Name);
                        EditorGUI.showMixedValue = !matchingSet;
                        EditorGUI.BeginChangeCheck();
                        bool newSet = EditorGUILayout.Toggle(set, GUILayout.Width(20));
                        EditorGUI.showMixedValue = false;

                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObjects(serializedObject.isEditingMultipleObjects ? serializedObject.targetObjects : new UnityEngine.Object[] { serializedObject.targetObject }, "Inspector");
                            if (newSet)
                            {
                                AddParameterValue(paramRef.Name, paramRef.Default);
                            }
                            else
                            {
                                DeleteParameterValue(paramRef.Name);
                            }
                            set = newSet;
                        }

                        EditorGUI.BeginDisabledGroup(!newSet);
                        if (set)
                        {
                            EditorGUI.showMixedValue = !matchingValue;
                            EditorGUI.BeginChangeCheck();
                            value = EditorGUILayout.Slider(value, paramRef.Min, paramRef.Max);
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObjects(serializedObject.isEditingMultipleObjects ? serializedObject.targetObjects : new UnityEngine.Object[] { serializedObject.targetObject }, "Inspector");
                                SetParameterValue(paramRef.Name, value);
                            }
                            EditorGUI.showMixedValue = false;
                        }
                        else
                        {
                            EditorGUI.showMixedValue = !matchingValue;
                            EditorGUILayout.Slider(paramRef.Default, paramRef.Min, paramRef.Max);
                            EditorGUI.showMixedValue = false;
                        }
                        EditorGUI.EndDisabledGroup();
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }

            fadeout.isExpanded = EditorGUILayout.Foldout(fadeout.isExpanded, "Advanced Controls");
            if (fadeout.isExpanded)
            {
                EditorGUILayout.PropertyField(preload, new GUIContent("Preload Sample Data"));
                EditorGUILayout.PropertyField(fadeout, new GUIContent("Allow Fadeout When Stopping"));
                EditorGUILayout.PropertyField(once, new GUIContent("Trigger Once"));
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemple #23
0
        override public void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(3);
            EditorGUIUtils.SetGUIStyles();

            bool playMode = Application.isPlaying;

            _runtimeEditMode = _runtimeEditMode && playMode;

            GUILayout.BeginHorizontal();
            EditorGUIUtils.InspectorLogo();
            GUILayout.Label(_src.animationType.ToString() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle);
            // Up-down buttons
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("▲", DeGUI.styles.button.toolIco))
            {
                UnityEditorInternal.ComponentUtility.MoveComponentUp(_src);
            }
            if (GUILayout.Button("▼", DeGUI.styles.button.toolIco))
            {
                UnityEditorInternal.ComponentUtility.MoveComponentDown(_src);
            }
            GUILayout.EndHorizontal();

            if (playMode)
            {
                if (_runtimeEditMode)
                {
                }
                else
                {
                    GUILayout.Space(8);
                    GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle);
                    if (!_src.isActive)
                    {
                        GUILayout.Label("This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle);
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button(new GUIContent("Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them")))
                    {
                        _runtimeEditMode = true;
                    }
                    GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle);
                    GUILayout.Space(10);
                    if (!_runtimeEditMode)
                    {
                        return;
                    }
                }
            }

            Undo.RecordObject(_src, "DOTween Animation");

//            _src.isValid = Validate(); // Moved down

            EditorGUIUtility.labelWidth = 120;

            if (playMode)
            {
                GUILayout.Space(4);
                DeGUILayout.Toolbar("Edit Mode Commands");
                DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("TogglePause"))
                {
                    _src.tween.TogglePause();
                }
                if (GUILayout.Button("Rewind"))
                {
                    _src.tween.Rewind();
                }
                if (GUILayout.Button("Restart"))
                {
                    _src.tween.Restart();
                }
                GUILayout.EndHorizontal();
                if (GUILayout.Button("Commit changes and restart"))
                {
                    _src.tween.Rewind();
                    _src.tween.Kill();
                    if (_src.isValid)
                    {
                        _src.CreateTween();
                        _src.tween.Play();
                    }
                }
                GUILayout.Label("To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap);
                DeGUILayout.EndVBox();
            }
            else
            {
                bool hasManager = _src.GetComponent <DOTweenVisualManager>() != null;
                if (!hasManager)
                {
                    if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject")))
                    {
                        _src.gameObject.AddComponent <DOTweenVisualManager>();
                    }
                }
            }

            GUILayout.BeginHorizontal();
            DOTweenAnimationType prevAnimType = _src.animationType;

//                _src.animationType = (DOTweenAnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton);
            _src.isActive      = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(16));
            GUI.enabled        = _src.isActive;
            _src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]);
            _src.autoPlay      = DeGUILayout.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically"));
            _src.autoKill      = DeGUILayout.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable"));
            GUILayout.EndHorizontal();
            if (prevAnimType != _src.animationType)
            {
                // Set default optional values based on animation type
                switch (_src.animationType)
                {
                case DOTweenAnimationType.Move:
                case DOTweenAnimationType.LocalMove:
                case DOTweenAnimationType.Rotate:
                case DOTweenAnimationType.LocalRotate:
                case DOTweenAnimationType.Scale:
                    _src.endValueV3    = Vector3.zero;
                    _src.endValueFloat = 0;
                    _src.optionalBool0 = _src.animationType == DOTweenAnimationType.Scale;
                    break;

                case DOTweenAnimationType.Color:
                case DOTweenAnimationType.Fade:
                    _src.endValueFloat = 0;
                    break;

                case DOTweenAnimationType.Text:
                    _src.optionalBool0 = true;
                    break;

                case DOTweenAnimationType.PunchPosition:
                case DOTweenAnimationType.PunchRotation:
                case DOTweenAnimationType.PunchScale:
                    _src.endValueV3     = _src.animationType == DOTweenAnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one;
                    _src.optionalFloat0 = 1;
                    _src.optionalInt0   = 10;
                    _src.optionalBool0  = false;
                    break;

                case DOTweenAnimationType.ShakePosition:
                case DOTweenAnimationType.ShakeRotation:
                case DOTweenAnimationType.ShakeScale:
                    _src.endValueV3     = _src.animationType == DOTweenAnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one;
                    _src.optionalInt0   = 10;
                    _src.optionalFloat0 = 90;
                    _src.optionalBool0  = false;
                    break;

                case DOTweenAnimationType.CameraAspect:
                case DOTweenAnimationType.CameraFieldOfView:
                case DOTweenAnimationType.CameraOrthoSize:
                    _src.endValueFloat = 0;
                    break;

                case DOTweenAnimationType.CameraPixelRect:
                case DOTweenAnimationType.CameraRect:
                    _src.endValueRect = new Rect(0, 0, 0, 0);
                    break;
                }
            }
            if (_src.animationType == DOTweenAnimationType.None)
            {
                _src.isValid = false;
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(_src);
                }
                return;
            }

            if (prevAnimType != _src.animationType || ComponentsChanged())
            {
                _src.isValid = Validate();
            }

            if (!_src.isValid)
            {
                GUI.color = Color.red;
                GUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle);
                GUILayout.EndVertical();
                GUI.color = Color.white;
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(_src);
                }
                return;
            }

            _src.duration = EditorGUILayout.FloatField("Duration", _src.duration);
            if (_src.duration < 0)
            {
                _src.duration = 0;
            }
            _src.delay = EditorGUILayout.FloatField("Delay", _src.delay);
            if (_src.delay < 0)
            {
                _src.delay = 0;
            }
            _src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate);
            _src.easeType            = EditorGUIUtils.FilteredEasePopup(_src.easeType);
            if (_src.easeType == Ease.INTERNAL_Custom)
            {
                _src.easeCurve = EditorGUILayout.CurveField("   Ease Curve", _src.easeCurve);
            }
            _src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops);
            if (_src.loops < -1)
            {
                _src.loops = -1;
            }
            if (_src.loops > 1 || _src.loops == -1)
            {
                _src.loopType = (LoopType)EditorGUILayout.EnumPopup("   Loop Type", _src.loopType);
            }
            _src.id = EditorGUILayout.TextField("ID", _src.id);

            bool canBeRelative = true;

            // End value and eventual specific options
            switch (_src.animationType)
            {
            case DOTweenAnimationType.Move:
            case DOTweenAnimationType.LocalMove:
                GUIEndValueV3();
                _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                break;

            case DOTweenAnimationType.Rotate:
            case DOTweenAnimationType.LocalRotate:
                if (_src.GetComponent <Rigidbody2D>())
                {
                    GUIEndValueFloat();
                }
                else
                {
                    GUIEndValueV3();
                    _src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup("    Rotation Mode", _src.optionalRotationMode);
                }
                break;

            case DOTweenAnimationType.Scale:
                if (_src.optionalBool0)
                {
                    GUIEndValueFloat();
                }
                else
                {
                    GUIEndValueV3();
                }
                _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
                break;

            case DOTweenAnimationType.Color:
                GUIEndValueColor();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.Fade:
                GUIEndValueFloat();
                if (_src.endValueFloat < 0)
                {
                    _src.endValueFloat = 0;
                }
                if (_src.endValueFloat > 1)
                {
                    _src.endValueFloat = 1;
                }
                canBeRelative = false;
                break;

            case DOTweenAnimationType.Text:
                GUIEndValueString();
                _src.optionalBool0        = EditorGUILayout.Toggle("Rich Content Enabled", _src.optionalBool0);
                _src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode);
                _src.optionalString       = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString);
                break;

            case DOTweenAnimationType.PunchPosition:
            case DOTweenAnimationType.PunchRotation:
            case DOTweenAnimationType.PunchScale:
                GUIEndValueV3();
                canBeRelative       = false;
                _src.optionalInt0   = EditorGUILayout.IntSlider(new GUIContent("    Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50);
                _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent("    Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1);
                if (_src.animationType == DOTweenAnimationType.PunchPosition)
                {
                    _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                }
                break;

            case DOTweenAnimationType.ShakePosition:
            case DOTweenAnimationType.ShakeRotation:
            case DOTweenAnimationType.ShakeScale:
                GUIEndValueV3();
                canBeRelative       = false;
                _src.optionalInt0   = EditorGUILayout.IntSlider(new GUIContent("    Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50);
                _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent("    Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90);
                if (_src.animationType == DOTweenAnimationType.ShakePosition)
                {
                    _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                }
                break;

            case DOTweenAnimationType.CameraAspect:
            case DOTweenAnimationType.CameraFieldOfView:
            case DOTweenAnimationType.CameraOrthoSize:
                GUIEndValueFloat();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.CameraBackgroundColor:
                GUIEndValueColor();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.CameraPixelRect:
            case DOTweenAnimationType.CameraRect:
                GUIEndValueRect();
                canBeRelative = false;
                break;
            }

            // Final settings
            if (canBeRelative)
            {
                _src.isRelative = EditorGUILayout.Toggle("    Relative", _src.isRelative);
            }

            // Events
            AnimationInspectorGUI.AnimationEvents(this, _src);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_src);
            }
        }
Exemple #24
0
        private void SetParamGUI(List <ActionParameter> parameters, List <ActionParameter> ownParameters = null, bool forceConstantIDs = false)
        {
            if (parameters == null || parameters.Count == 0)
            {
                parameterLabel = "";
                return;
            }

            _parameter = GetParameterWithID(parameters, parameterID);

            if (_parameter == null)
            {
                parameterLabel = "";
                return;
            }

            parameterLabel = _parameter.label;

            setParamMethod = (SetParamMethod)EditorGUILayout.EnumPopup("New value is:", setParamMethod);

            if (setParamMethod == SetParamMethod.EnteredHere)
            {
                if (ownParameters != null && ownParameters.Count > 0)
                {
                    ownParamID = Action.ChooseParameterGUI("Set as:", ownParameters, ownParamID, _parameter.parameterType);
                    if (ownParamID >= 0)
                    {
                        return;
                    }
                }

                if (_parameter.parameterType == ParameterType.Boolean)
                {
                    bool boolValue = (intValue == 1) ? true : false;
                    boolValue = EditorGUILayout.Toggle("Set as:", boolValue);
                    intValue  = (boolValue) ? 1 : 0;
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    intValue = EditorGUILayout.IntField("Set as:", intValue);
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    floatValue = EditorGUILayout.FloatField("Set as:", floatValue);
                }
                else if (_parameter.parameterType == ParameterType.String)
                {
                    stringValue = EditorGUILayout.TextField("Set as:", stringValue);
                }
                else if (_parameter.parameterType == ParameterType.GameObject)
                {
                    gameobjectValue = (GameObject)EditorGUILayout.ObjectField("Set to:", gameobjectValue, typeof(GameObject), true);

                    gameObjectConstantID = FieldToID(gameobjectValue, gameObjectConstantID, forceConstantIDs);
                    gameobjectValue      = IDToField(gameobjectValue, gameObjectConstantID, false, forceConstantIDs);
                }
                else if (_parameter.parameterType == ParameterType.GlobalVariable)
                {
                    if (AdvGame.GetReferences().variablesManager == null || AdvGame.GetReferences().variablesManager.vars == null || AdvGame.GetReferences().variablesManager.vars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Global variables exist!", MessageType.Info);
                    }
                    else
                    {
                        intValue = ShowVarSelectorGUI(AdvGame.GetReferences().variablesManager.vars, intValue);
                    }
                }
                else if (_parameter.parameterType == ParameterType.UnityObject)
                {
                    unityObjectValue = (Object)EditorGUILayout.ObjectField("Set to:", unityObjectValue, typeof(Object), true);
                }
                else if (_parameter.parameterType == ParameterType.InventoryItem)
                {
                    intValue = ShowInvSelectorGUI(intValue);
                }
                else if (_parameter.parameterType == ParameterType.LocalVariable)
                {
                    if (isAssetFile)
                    {
                        EditorGUILayout.HelpBox("Cannot access local variables from an asset file.", MessageType.Warning);
                    }
                    else if (KickStarter.localVariables == null || KickStarter.localVariables.localVars == null || KickStarter.localVariables.localVars.Count == 0)
                    {
                        EditorGUILayout.HelpBox("No Local variables exist!", MessageType.Info);
                    }
                    else
                    {
                        intValue = ShowVarSelectorGUI(KickStarter.localVariables.localVars, intValue);
                    }
                }
                else if (_parameter.parameterType == ParameterType.Vector3)
                {
                    vector3Value = EditorGUILayout.Vector3Field("Set as:", vector3Value);
                }
            }
            else if (setParamMethod == SetParamMethod.Random)
            {
                if (_parameter.parameterType == ParameterType.Boolean)
                {
                }
                else if (_parameter.parameterType == ParameterType.Integer)
                {
                    intValue    = EditorGUILayout.IntField("Minimum:", intValue);
                    intValueMax = EditorGUILayout.IntField("Maximum:", intValueMax);
                    if (intValueMax < intValue)
                    {
                        intValueMax = intValue;
                    }
                }
                else if (_parameter.parameterType == ParameterType.Float)
                {
                    floatValue    = EditorGUILayout.FloatField("Minimum:", floatValue);
                    floatValueMax = EditorGUILayout.FloatField("Maximum:", floatValueMax);
                    if (floatValueMax < floatValue)
                    {
                        floatValueMax = floatValue;
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Parameters of type '" + _parameter.parameterType + "' cannot be set randomly.", MessageType.Warning);
                }
            }
            else if (setParamMethod == SetParamMethod.CopiedFromGlobalVariable)
            {
                if (AdvGame.GetReferences() != null && AdvGame.GetReferences().variablesManager != null && AdvGame.GetReferences().variablesManager.vars != null && AdvGame.GetReferences().variablesManager.vars.Count > 0)
                {
                    if (_parameter.parameterType == ParameterType.Vector3)
                    {
                        globalVariableID = AdvGame.GlobalVariableGUI("Vector3 variable:", globalVariableID, VariableType.Vector3);
                    }
                    else if (_parameter.parameterType == ParameterType.GameObject || _parameter.parameterType == ParameterType.GlobalVariable || _parameter.parameterType == ParameterType.InventoryItem || _parameter.parameterType == ParameterType.LocalVariable || _parameter.parameterType == ParameterType.UnityObject)
                    {
                        EditorGUILayout.HelpBox("Parameters of type '" + _parameter.parameterType + "' cannot have values transferred from Global Variables.", MessageType.Warning);
                    }
                    else
                    {
                        globalVariableID = AdvGame.GlobalVariableGUI("Variable:", globalVariableID);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No Global Variables found!", MessageType.Warning);
                }
            }
            else if (setParamMethod == SetParamMethod.CopiedFromParameter)
            {
                if (changeOwn)
                {
                    parameterToCopyID = Action.ChooseParameterGUI(parameters, parameterToCopyID);
                }
                else
                {
                    if (actionListSource == ActionListSource.InScene && actionList != null)
                    {
                        if (actionList.source == ActionListSource.InScene)
                        {
                            if (actionList.useParameters && actionList.parameters.Count > 0)
                            {
                                parameterToCopyID = Action.ChooseParameterGUI(actionList.parameters, parameterToCopyID);
                            }
                        }
                        else if (actionList.source == ActionListSource.AssetFile && actionList.assetFile != null)
                        {
                            if (actionList.assetFile.useParameters && actionList.assetFile.parameters.Count > 0)
                            {
                                parameterToCopyID = Action.ChooseParameterGUI(actionList.assetFile.parameters, parameterToCopyID);
                            }
                        }
                    }
                    else if (actionListSource == ActionListSource.AssetFile && actionListAsset != null)
                    {
                        if (actionListAsset.useParameters && actionListAsset.parameters.Count > 0)
                        {
                            parameterToCopyID = Action.ChooseParameterGUI(actionListAsset.parameters, parameterToCopyID);
                        }
                    }
                }
            }
        }
Exemple #25
0
        public static void Draw(NEDataProperty[] properties, params GUILayoutOption[] options)
        {
            if (properties == null)
            {
                return;
            }
            EditorGUILayout.BeginVertical(options);

            foreach (NEDataProperty property in properties)
            {
                object oldValue = property.GetValue();
                object newValue = null;
                switch (property.Type)
                {
                case NEDatapRropertyType.Integer:
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(property.Name);
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    Space(3);
                    newValue = EditorGUILayout.IntField((int)oldValue, options);
                    EditorGUILayout.EndHorizontal();
                    break;

                case NEDatapRropertyType.Float:
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(property.Name);
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    Space(3);
                    newValue = EditorGUILayout.FloatField((float)oldValue, options);
                    EditorGUILayout.EndHorizontal();
                    break;

                case NEDatapRropertyType.FP:
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(property.Name);
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    Space(3);
                    float oldFloatValue = ((FP)oldValue).AsFloat();
                    float newFloatValue = EditorGUILayout.FloatField(oldFloatValue, options);
                    newValue = FP.FromFloat(newFloatValue);
                    EditorGUILayout.EndHorizontal();
                    break;

                case NEDatapRropertyType.Boolean:
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(property.Name);
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    Space(3);
                    newValue = EditorGUILayout.Toggle((bool)oldValue, options);
                    EditorGUILayout.EndHorizontal();
                    break;

                case NEDatapRropertyType.String:
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(property.Name);
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    Space(3);
                    newValue = EditorGUILayout.TextField((String)oldValue, options);
                    EditorGUILayout.EndHorizontal();
                    break;

                case NEDatapRropertyType.Vector2:
                    newValue = EditorGUILayout.Vector2Field(property.Name, (Vector2)oldValue, options);
                    break;

                case NEDatapRropertyType.Vector3:
                    newValue = EditorGUILayout.Vector3Field(property.Name, (Vector3)oldValue, options);
                    break;

                case NEDatapRropertyType.Enum:
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(property.Name);
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    Space(3);
                    newValue = EditorGUILayout.EnumPopup((Enum)oldValue, options);
                    EditorGUILayout.EndHorizontal();
                    break;

                case NEDatapRropertyType.Array:
                    EditorGUILayout.BeginHorizontal();
                    property.isShow = EditorGUILayout.Foldout(property.isShow, property.Name);
                    EditorGUILayout.EndHorizontal();
                    newValue = property.GetValue();
                    if (property.isShow)
                    {
                        EditorGUILayout.BeginHorizontal();
                        Space(3);
                        int oldLen = property.GetArrayLen();
                        int newLen = EditorGUILayout.IntField("Len:", oldLen, options);
                        if (oldLen != newLen)
                        {
                            property.SetArrayLen(newLen);
                        }
                        EditorGUILayout.EndHorizontal();

                        EditorGUILayout.BeginHorizontal();
                        Space(3);
                        var array = newValue as Array;

                        if (array != null)
                        {
                            DrawArray(array, options);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    break;

                default:
                    break;
                }

                if (oldValue != newValue)
                {
                    property.SetValue(newValue);
                }
            }

            EditorGUILayout.EndVertical();
        }
    public override void OnInspectorGUI()
    {
        
        base.OnInspectorGUI();
        KATDevice KATdevice = (KATDevice)target;
        //wXML();
        LoadLanguageFile(KATdevice.displayLanguage);
        /* 基础选项 */
        KATdevice.displayLanguage = (KATDevice.LanguageList)EditorGUILayout.EnumPopup(word[0], KATdevice.displayLanguage);
        KATdevice.device = (KATDevice.DeviceTypeList)EditorGUILayout.EnumPopup(word[1], KATdevice.device);
        EditorGUILayout.Space();
        /* 通用变量 */
        #region 通用变量
        KATdevice.targetMoveObject = (Transform)EditorGUILayout.ObjectField(word[2], KATdevice.targetMoveObject, typeof(Transform), true);
        KATdevice.targetRotateObject = (Transform)EditorGUILayout.ObjectField(word[16], KATdevice.targetRotateObject, typeof(Transform), true);
        KATdevice.vrCameraRig = (Transform)EditorGUILayout.ObjectField(word[3], KATdevice.vrCameraRig, typeof(Transform), true);
        KATdevice.vrHandset = (Transform)EditorGUILayout.ObjectField(word[4], KATdevice.vrHandset, typeof(Transform), true);
        #endregion
        EditorGUILayout.Space();
        #region For KAT WALK
        if (KATdevice.device == KATDevice.DeviceTypeList.KAT_WALK)
        {
            KATdevice.MovementStyle = (KATDevice.MovementStyleList)EditorGUILayout.EnumPopup(word[6], KATdevice.MovementStyle);
            EditorGUILayout.BeginHorizontal();
            KATdevice.multiply = EditorGUILayout.FloatField(word[5], KATdevice.multiply);
            if (GUILayout.Button(word[15], GUILayout.Width(75))) KATdevice.multiply = 1;
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            KATdevice.multiplyBack = EditorGUILayout.FloatField(word[14], KATdevice.multiplyBack);
            if (GUILayout.Button(word[15], GUILayout.Width(75))) KATdevice.multiplyBack = 0.3f;
            EditorGUILayout.EndHorizontal();


            if (GUI.changed)
            {
                EditorUtility.SetDirty(KATdevice);
            }

            KATdevice.ResetCameraKey = (KeyCode)EditorGUILayout.EnumPopup(word[13], KATdevice.ResetCameraKey);
            EditorGUILayout.Space();
            #region Displayed Variable
            if (KATVR_Global.KDevice_Walk != null)
            {
                EditorGUILayout.Slider(word[7], KATVR_Global.KDevice_Walk.data_DisplayedSpeed, 0, 1);
                EditorGUILayout.Slider(word[8], KATVR_Global.KDevice_Walk.data_bodyYaw, 0, 360);
                if (KATVR_Global.KDevice_Walk.data_isMoving == 1)
                {
                    if (KATVR_Global.KDevice_Walk.data_moveDirection > 0)
                        EditorGUILayout.LabelField(word[9], word[11]);
                    else if (KATVR_Global.KDevice_Walk.data_moveDirection < 0)
                        EditorGUILayout.LabelField(word[9], word[12]);
                }
                else
                {
                    EditorGUILayout.LabelField(word[9], word[10]);
                }
            }
            #endregion
        }
        #endregion



    }
    private Effect DrawEffect(Effect entry)
    {
        entry.eventOptions = EditorHelper.DrawExtendedList("Event Options", entry.eventOptions, "Option", DrawEventOptions);

        EditorGUILayout.Separator();

        entry.deliveryMethod = EditorHelper.EnumPopup("Delivery method", entry.deliveryMethod);

        DrawDeliveryMethod(entry);


        entry.applyToSpecificTarget = EditorGUILayout.Toggle("Apply to Xth hit Target?", entry.applyToSpecificTarget);

        if (entry.applyToSpecificTarget)
        {
            entry.targetIndex = EditorGUILayout.IntField("Which Hit?", entry.targetIndex);
        }

        //entry.requireMultipleHits = EditorGUILayout.Toggle("Require Multiple Triggers?", entry.requireMultipleHits);
        //if (entry.requireMultipleHits) {
        //    entry.requiredHits = EditorGUILayout.IntField("Number of Triggers", entry.requiredHits);
        //}

        //Attacks
        if (entry is EffectAttack)
        {
            EffectAttack attackEffect = entry as EffectAttack;
            attackEffect.effectType = Constants.SpecialAbilityEffectType.AttackEffect;

            attackEffect.effectDamage = EditorGUILayout.IntField("Efect Base Damage", attackEffect.effectDamage) * -1;

            attackEffect.scaleFromBaseDamage = EditorGUILayout.Toggle("Scale From Entity base damage?", attackEffect.scaleFromBaseDamage);
            if (attackEffect.scaleFromBaseDamage)
            {
                attackEffect.percentOfBaseDamage = EditorHelper.PercentFloatField("Percent of base damage", attackEffect.percentOfBaseDamage);
            }
            EditorGUILayout.Separator();

            attackEffect.burstAttack = EditorGUILayout.Toggle("Burst?", attackEffect.burstAttack);

            if (attackEffect.burstAttack)
            {
                attackEffect.burstInterval = EditorGUILayout.FloatField("Delay between shots", attackEffect.burstInterval);
                attackEffect.burstNumber   = EditorGUILayout.IntField("Number of shots", attackEffect.burstNumber);
                EditorGUILayout.Separator();
            }

            attackEffect.penetrate = EditorGUILayout.Toggle("Penetrating?", attackEffect.penetrate);
            if (attackEffect.penetrate)
            {
                attackEffect.numPenetrations = EditorGUILayout.IntField("Number of Penetrations (0 = INF)", attackEffect.numPenetrations);
            }

            EditorGUILayout.Separator();
            attackEffect.fireEffectName   = EditorGUILayout.TextField("Fire Effect Name", attackEffect.fireEffectName);
            attackEffect.impactEffectName = EditorGUILayout.TextField("Impact Effect Name", attackEffect.impactEffectName);
        }

        //Status Effects
        if (entry is EffectStatus)
        {
            EffectStatus statusAttack = entry as EffectStatus;
            statusAttack.effectType           = Constants.SpecialAbilityEffectType.StatusEffect;
            statusAttack.stackMethod          = EditorHelper.EnumPopup("Stack Method", statusAttack.stackMethod);
            statusAttack.onCompleteEffectName = EditorGUILayout.TextField("On Complete Effect Name", statusAttack.onCompleteEffectName);

            switch (statusAttack.stackMethod)
            {
            case Constants.StatusStackingMethod.LimitedStacks:
                statusAttack.maxStack = EditorGUILayout.IntField("Max Stacks?", statusAttack.maxStack);
                break;
            }

            statusAttack.statusType = EditorHelper.EnumPopup("Status Type", statusAttack.statusType);
            statusAttack.duration   = EditorGUILayout.FloatField("Duration (0 = INF)", statusAttack.duration);
            statusAttack.interval   = EditorGUILayout.FloatField("Interval Time", statusAttack.interval);


            switch (statusAttack.statusType)
            {
            case Constants.StatusEffectType.AffectMovement:
                statusAttack.affectMoveType = EditorHelper.EnumPopup("Movement Affect Type", statusAttack.affectMoveType);

                if (statusAttack.affectMoveType != AffectMovement.AffectMovementType.Halt)
                {
                    statusAttack.affectMoveValue = EditorHelper.FloatField("Value", statusAttack.affectMoveValue);
                }

                if (statusAttack.affectMoveType == AffectMovement.AffectMovementType.Knockback)
                {
                    statusAttack.knocbackAngle = EditorHelper.FloatField("Angle", statusAttack.knocbackAngle);
                }

                break;

            case Constants.StatusEffectType.DamageOverTime:

                statusAttack.damagePerInterval   = EditorGUILayout.FloatField("Damage Per Interval", statusAttack.damagePerInterval) * -1;
                statusAttack.scaleFromBaseDamage = EditorGUILayout.Toggle("Scale from Base Damage?", statusAttack.scaleFromBaseDamage);

                if (statusAttack.scaleFromBaseDamage)
                {
                    statusAttack.percentOfBaseDamage = EditorHelper.PercentFloatField("Percentage of Base Damage", statusAttack.percentOfBaseDamage);
                }

                break;

            case Constants.StatusEffectType.StaticStatAdjustment:
            case Constants.StatusEffectType.DurationalStatAdjustment:
                statusAttack.statType = EditorHelper.EnumPopup("Stat Type", statusAttack.statType);
                switch (statusAttack.statType)
                {
                case Constants.BaseStatType.BaseDamage:
                    statusAttack.statAdjustmentValue = EditorGUILayout.FloatField("Value", statusAttack.statAdjustmentValue) * -1;
                    break;

                default:
                    statusAttack.statAdjustmentValue = EditorHelper.FloatField("Value", statusAttack.statAdjustmentValue);
                    break;
                }

                statusAttack.modType = EditorHelper.EnumPopup("Mod Type", statusAttack.modType);

                break;
            }
        }


        return(entry);
    }
Exemple #28
0
    override public void OnInspectorGUI()
    {
        serializedObject.Update();
        SkeletonDataAsset asset = (SkeletonDataAsset)target;

        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(atlasAsset);
        EditorGUILayout.PropertyField(skeletonJSON);
        EditorGUILayout.PropertyField(scale);
        if (EditorGUI.EndChangeCheck())
        {
            if (m_previewUtility != null)
            {
                m_previewUtility.Cleanup();
                m_previewUtility = null;
            }
        }

        SkeletonData skeletonData = asset.GetSkeletonData(asset.atlasAsset == null || asset.skeletonJSON == null);

        if (skeletonData != null)
        {
            showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
            if (showAnimationStateData)
            {
                EditorGUILayout.PropertyField(defaultMix);

                // Animation names
                String[] animations = new String[skeletonData.Animations.Count];
                for (int i = 0; i < animations.Length; i++)
                {
                    animations[i] = skeletonData.Animations[i].Name;
                }

                for (int i = 0; i < fromAnimation.arraySize; i++)
                {
                    SerializedProperty from         = fromAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty to           = toAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty durationProp = duration.GetArrayElementAtIndex(i);
                    EditorGUILayout.BeginHorizontal();
                    from.stringValue        = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)];
                    to.stringValue          = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)];
                    durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue);
                    if (GUILayout.Button("Delete"))
                    {
                        duration.DeleteArrayElementAtIndex(i);
                        toAnimation.DeleteArrayElementAtIndex(i);
                        fromAnimation.DeleteArrayElementAtIndex(i);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("Add Mix"))
                {
                    duration.arraySize++;
                    toAnimation.arraySize++;
                    fromAnimation.arraySize++;
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button(new GUIContent("Setup Pose", SpineEditorUtilities.Icons.skeleton), GUILayout.Width(105), GUILayout.Height(18)))
            {
                StopAnimation();
                m_skeletonAnimation.skeleton.SetToSetupPose();
                m_requireRefresh = true;
            }

                        #if UNITY_4_3
            m_showAnimationList = EditorGUILayout.Foldout(m_showAnimationList, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot));
            if (m_showAnimationList)
            {
                        #else
            m_showAnimationList.target = EditorGUILayout.Foldout(m_showAnimationList.target, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot));
            if (EditorGUILayout.BeginFadeGroup(m_showAnimationList.faded))
            {
                                #endif



                EditorGUILayout.LabelField("Name", "Duration");
                foreach (Spine.Animation a in skeletonData.Animations)
                {
                    GUILayout.BeginHorizontal();

                    if (m_skeletonAnimation != null && m_skeletonAnimation.state != null)
                    {
                        if (m_skeletonAnimation.state.GetCurrent(0) != null && m_skeletonAnimation.state.GetCurrent(0).Animation == a)
                        {
                            GUI.contentColor = Color.black;
                            if (GUILayout.Button("\u25BA", GUILayout.Width(24)))
                            {
                                StopAnimation();
                            }
                            GUI.contentColor = Color.white;
                        }
                        else
                        {
                            if (GUILayout.Button("\u25BA", GUILayout.Width(24)))
                            {
                                PlayAnimation(a.Name, true);
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("?", GUILayout.Width(24));
                    }
                    EditorGUILayout.LabelField(new GUIContent(a.Name, SpineEditorUtilities.Icons.animation), new GUIContent(a.Duration.ToString("f3") + "s" + ("(" + (Mathf.RoundToInt(a.Duration * 30)) + ")").PadLeft(12, ' ')));
                    GUILayout.EndHorizontal();
                }
            }
                        #if !UNITY_4_3
            EditorGUILayout.EndFadeGroup();
                        #endif
        }

        if (!Application.isPlaying)
        {
            if (serializedObject.ApplyModifiedProperties() ||
                (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
                )
            {
                asset.Reset();
            }
        }
    }
Exemple #29
0
    public override void OnInspectorGUI()
    {
        foreach (SpawnManager.Levels level in mTarget.Level)
        {
            EditorGUILayout.BeginVertical("Box");

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("X", GUILayout.Width(30.0f)))
            {
                mTarget.Level.Remove(level);
                return;
            }
            level.Name = EditorGUILayout.TextField("Level name", level.Name);
            EditorGUILayout.EndHorizontal();

            mTarget.preparationTime = EditorGUILayout.Toggle("Preparation Time: ", mTarget.preparationTime);

            for (int i = 0; i < level.Wave.Count; ++i)
            {
                SpawnManager.Waves wave = level.Wave[i];

                BeginIndent();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("X", GUILayout.Width(30.0f)))
                {
                    level.Wave.Remove(wave);
                    return;
                }
                GUILayout.Label("Wave " + (i + 1));
                EditorGUILayout.EndHorizontal();

                wave.waveStart = EditorGUILayout.Toggle("Wave Start: ", wave.waveStart);

                for (int j = 0; j < wave.Group.Count; ++j)
                {
                    SpawnManager.Groups group = wave.Group[j];
                    BeginIndent();

                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("X", GUILayout.Width(30.0f)))
                    {
                        wave.Group.Remove(group);
                        return;
                    }
                    GUILayout.Label("Group " + (j + 1));
                    EditorGUILayout.EndHorizontal();

                    group.groupSpawnInterval = EditorGUILayout.FloatField("Group Spawn Interval: ", group.groupSpawnInterval);

                    group.enemyType          = (GameObject)EditorGUILayout.ObjectField("Enemy Type: ", group.enemyType, typeof(GameObject), false);
                    group.spawnAmount        = EditorGUILayout.IntField("Spawn Amount: ", group.spawnAmount);
                    group.enemySpawnInterval = EditorGUILayout.FloatField("Spawn Interval: ", group.enemySpawnInterval);



                    EndIndent();
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(175.0f);
                if (GUILayout.Button("Add Group"))
                {
                    wave.Group.Add(new SpawnManager.Groups());
                    return;
                }
                EditorGUILayout.EndHorizontal();
                EndIndent();
            }

            GUILayout.Space(10.0f);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(30.0f);
            if (GUILayout.Button("Add Wave"))
            {
                level.Wave.Add(new SpawnManager.Waves());
                return;
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10.0f);

            EditorGUILayout.EndVertical();
        }


        if (GUILayout.Button("Add Level"))
        {
            mTarget.Level.Add(new SpawnManager.Levels());
        }
    }
Exemple #30
0
        private void ButtonGUI(Button button, string suffix, InteractionSource source)
        {
            bool isEnabled = !button.isDisabled;

            isEnabled         = EditorGUILayout.Toggle("Enabled:", isEnabled);
            button.isDisabled = !isEnabled;

            if (source == InteractionSource.AssetFile)
            {
                button.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", button.assetFile, typeof(ActionListAsset), false);
            }
            else if (source == InteractionSource.CustomScript)
            {
                button.customScriptObject   = (GameObject)EditorGUILayout.ObjectField("Object with script:", button.customScriptObject, typeof(GameObject), true);
                button.customScriptFunction = EditorGUILayout.TextField("Message to send:", button.customScriptFunction);
            }
            else if (source == InteractionSource.InScene)
            {
                EditorGUILayout.BeginHorizontal();
                button.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", button.interaction, typeof(Interaction), true);

                if (button.interaction == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        Undo.RecordObject(_target, "Create Interaction");
                        Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>();

                        string hotspotName = _target.gameObject.name;
                        if (_target != null && _target.hotspotName != null && _target.hotspotName.Length > 0)
                        {
                            hotspotName = _target.hotspotName;
                        }

                        newInteraction.gameObject.name = AdvGame.UniqueName(hotspotName + ": " + suffix);
                        button.interaction             = newInteraction;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            button.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", button.playerAction);

            if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker)
            {
                if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null)
                {
                    EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning);
                }
                button.isBlocking = EditorGUILayout.Toggle("Cutscene while moving?", button.isBlocking);
                button.faceAfter  = EditorGUILayout.Toggle("Face after moving?", button.faceAfter);

                if (button.playerAction == PlayerAction.WalkTo)
                {
                    button.setProximity = EditorGUILayout.Toggle("Set minimum distance?", button.setProximity);
                    if (button.setProximity)
                    {
                        button.proximity = EditorGUILayout.FloatField("Proximity:", button.proximity);
                    }
                }
            }
        }