public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            EditorGUI.BeginProperty(pos, label, prop);

            float origX     = pos.x;
            float origWidth = pos.width;

            SerializedProperty runTargetProp = DrawRunTargetAndCallMethod(ref pos, prop, 125);

            SerializedProperty numCheckProp = prop.FindPropertyRelative("numericalCheck");

            pos.width = numericalCheckWidth;
            numCheckProp.enumValueIndex = EditorGUI.Popup(pos, numCheckProp.enumValueIndex, numericalCheckOptions);
            pos.x += pos.width;

            SerializedProperty useGlobalValueThresholdProp = prop.FindPropertyRelative("useGlobalValueThreshold");
            bool useGlobalValueThreshold = useGlobalValueThresholdProp.boolValue;


            if (useGlobalValueThreshold)
            {
                pos.width = 100;
                GlobalGameValues.DrawGlobalValueSelector(pos, prop.FindPropertyRelative("globalValueThresholdName"));
                pos.x += 75;
            }
            else
            {
                pos.width = 60;
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("threshold"), GUITools.noContent, true);
                pos.x += pos.width;
            }

            GUITools.DrawToolbarDivider(pos.x, pos.y);
            pos.x += GUITools.toolbarDividerSize;

            GUITools.DrawIconToggle(useGlobalValueThresholdProp, useGlobalValueGUI, pos.x, pos.y);
            pos.x += GUITools.iconButtonWidth;

            SerializedProperty trueIfSubjectNullProp = prop.FindPropertyRelative("trueIfSubjectNull");

            GUITools.DrawIconToggle(trueIfSubjectNullProp, new GUIContent("[?]", "Consider True If Subject Is Null Or Method Check Fails"), pos.x, pos.y);
            pos.x += GUITools.iconButtonWidth;

            SerializedProperty orProp = prop.FindPropertyRelative("or");

            GUITools.DrawIconToggle(orProp, new GUIContent(orProp.boolValue ? "||" : "&&"), pos.x, pos.y, GUITools.white, GUITools.white);
            pos.x += GUITools.iconButtonWidth;

            DrawEnd(ref pos, prop, origX, origWidth, runTargetProp);

            EditorGUI.EndProperty();
        }
Exemplo n.º 2
0
        protected void DrawEnd(ref Rect pos, SerializedProperty prop, float origX, float origWidth, SerializedProperty runTargetProp)
        {
            prop.isExpanded = GUITools.DrawIconToggle(prop.isExpanded, new GUIContent("P", "Show Parameters"), pos.x, pos.y, GUITools.blue, GUITools.white);

            pos.x += GUITools.iconButtonWidth;

            if (runTargetProp.enumValueIndex == (int)RunTarget.Reference)
            {
                DrawReferenceTarget(ref pos, prop, origX, origWidth);
            }
            else if (runTargetProp.enumValueIndex == (int)RunTarget.Subject)
            {
                DrawRuntimeObjectName(ref pos, prop, origX, origWidth);
            }

            DrawParameters(ref pos, prop, prop.isExpanded, origX, origWidth);
        }
Exemplo n.º 3
0
        static void DrawPlayStopButton(AudioClip newClip, float x, float y, bool isPlaying, bool sourceState, GUIContent onGUI, bool looped, UnityEngine.Object targetObject)
        {
            bool wasEnabled = GUI.enabled;

            GUI.enabled = wasEnabled && (!isPlaying || sourceState);

            if (GUITools.DrawIconToggle(sourceState, onGUI, x, y))
            {
                if (isPlaying)
                {
                    EditorAudioTools.StopClip(newClip);
                }
                else
                {
                    EditorAudioTools.PlayClip(newClip, looped, targetObject);
                }
            }
            GUI.enabled = wasEnabled;
        }
Exemplo n.º 4
0
        void DrawToolbar(float x, float y, SerializedProperty prop, SerializedProperty oneShot, SerializedProperty is2D)
        {
            GUITools.DrawIconToggle(oneShot, BuiltInIcons.GetIcon("AudioListener Icon", "One Shot"), x, y);
            x += GUITools.iconButtonWidth;

            GUI.enabled = !oneShot.boolValue;
            GUITools.DrawIconToggle(prop.FindPropertyRelative("loop"), BuiltInIcons.GetIcon("preAudioLoopOff", "Looped"), x, y);
            x          += GUITools.iconButtonWidth;
            GUI.enabled = true;

            GUITools.DrawIconToggle(is2D, BuiltInIcons.GetIcon("Prefab Icon", "3D Sound"), x, y, GUITools.white, GUITools.blue);
            x += GUITools.iconButtonWidth;

            GUI.enabled = !is2D.boolValue;
            GUITools.DrawIconToggle(prop.FindPropertyRelative("useLinearRolloff"), BuiltInIcons.GetIcon("DefaultSorting", "Linear Roloff"), x, y);
            x          += GUITools.iconButtonWidth;
            GUI.enabled = true;

            prop.isExpanded = GUITools.DrawIconToggle(prop.isExpanded, BuiltInIcons.GetIcon("_Popup", "Advanced Settings"), x, y);
        }
Exemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.BeginHorizontal();

            GUITools.StringFieldWithDefault(serializedObject.FindProperty("valueName"), "Value Name");

            SerializedProperty behaviorProp = serializedObject.FindProperty("behavior");

            EditorGUILayout.PropertyField(behaviorProp, GUITools.noContent, true);
            GameValueModifierBehavior behavior = (GameValueModifierBehavior)behaviorProp.enumValueIndex;

            SerializedProperty componentProp = serializedObject.FindProperty("componentToModify");

            EditorGUILayout.PropertyField(componentProp, GUITools.noContent, true);
            GameValueModifierComponent component = (GameValueModifierComponent)componentProp.enumValueIndex;

            SerializedProperty byTimeProp = serializedObject.FindProperty("byTime");

            // cant modify by delta time if modifying base modifier or setting values
            if (component == GameValueModifierComponent.BaseMod || behavior == GameValueModifierBehavior.Set)
            {
                byTimeProp.boolValue = false;
            }
            else
            {
                GUITools.DrawIconToggle(byTimeProp, BuiltInIcons.GetIcon("UnityEditor.AnimationWindow", "Magnitude is multiplied by delta time when updated"));
            }

            EditorGUILayout.EndHorizontal();

            if (component == GameValueModifierComponent.BaseMod && behavior == GameValueModifierBehavior.Set)
            {
                EditorGUILayout.HelpBox("Cant set base value modifier.  Changes need to be able to be unmodified...", MessageType.Error);
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("conditions"), new GUIContent("Conditions"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("keywords"), new GUIContent("Keywords"), true);

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 6
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            SerializedProperty useAlias = prop.FindPropertyRelative("useAlias");

            GUITools.Box(new Rect(pos.x, pos.y, pos.width, CalcHeight(useAlias)), new Color32(0, 0, 0, 32));

            pos.height = GUITools.singleLineHeight;
            GUITools.Label(pos, label, GUITools.black, GUITools.boldLabel);

            GUITools.DrawIconToggle(useAlias, new GUIContent("A", "Use Alias"), pos.x + (pos.width - GUITools.iconButtonWidth), pos.y);


            pos.y += GUITools.singleLineHeight;

            if (useAlias.boolValue)
            {
                SerializedProperty aliasProp = prop.FindPropertyRelative("alias");
                DrawKeySelect(pos, aliasProp);

                GUI.enabled = !string.IsNullOrEmpty(aliasProp.stringValue);

                if (GUITools.IconButton(pos.x + (pos.width - GUITools.iconButtonWidth), pos.y, new GUIContent("G", "Go To Scene / Location"), GUITools.white))
                {
                    LocationKey key = LocationAliases.GetLocationKey(aliasProp.stringValue);
                    if (key != null)
                    {
                        LocationKeyDrawer.FastTravelToLocation(key.scene, key.name);
                    }
                }
                GUI.enabled = true;
            }
            else
            {
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("key"), true);
            }
        }
Exemplo n.º 7
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            EditorGUI.BeginProperty(pos, label, prop);

            pos.height = EditorGUIUtility.singleLineHeight;

            float origX = pos.x;
            float origW = pos.width;

            SerializedProperty isRangedProp   = prop.FindPropertyRelative("isRangedValue");
            SerializedProperty randomInitProp = prop.FindPropertyRelative("randomInitialization");

            SerializedProperty useBaseModifiersProp = prop.FindPropertyRelative("useBaseModifiers");

            bool randomInit = randomInitProp.boolValue;
            bool isRanged   = isRangedProp.boolValue;


            int buttonsCount = 4;//valueCapped ? 4 : 3;

            float allButtonsSpace = GUITools.iconButtonWidth * buttonsCount;

            float spaceWithoutButtons = pos.width - allButtonsSpace;

            // float offset = (allButtonsSpace + (spaceWithoutButtons * .5f));

            GUITools.StringFieldWithDefault(pos.x, pos.y, pos.width - (allButtonsSpace + (spaceWithoutButtons * .5f)), pos.height, prop.FindPropertyRelative("name"), "Value Name");

            randomInit = GUITools.DrawIconToggle(randomInitProp, randomInitGUI, pos.x + (pos.width - GUITools.iconButtonWidth * buttonsCount), pos.y, GUITools.blue, GUITools.white);

            buttonsCount--;
            isRanged = GUITools.DrawIconToggle(isRangedProp, cappedGUI, pos.x + (pos.width - GUITools.iconButtonWidth * buttonsCount), pos.y, GUITools.blue, GUITools.white);

            buttonsCount--;
            GUITools.DrawIconToggle(useBaseModifiersProp, useBaseModsGUI, pos.x + (pos.width - GUITools.iconButtonWidth * buttonsCount), pos.y, GUITools.blue, GUITools.white);


            bool showAdvanced = GUITools.DrawIconToggle(prop.FindPropertyRelative("showAdvanced"), showAdvancedGUI, pos.x + (pos.width - GUITools.iconButtonWidth), pos.y, GUITools.blue, GUITools.white);

            pos.x += spaceWithoutButtons * .5f;

            float labelWidth = 40;

            pos.width = labelWidth;
            EditorGUI.LabelField(pos, new GUIContent("Initial:"));
            pos.x += pos.width;

            pos.width = ((spaceWithoutButtons * .5f) - labelWidth) * (randomInit ? .5f : 1);
            EditorGUI.PropertyField(pos, prop.FindPropertyRelative("initMin"), GUITools.noContent);
            pos.x += pos.width;

            if (randomInit)
            {
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("initMax"), GUITools.noContent);
                pos.x += pos.width;
            }

            if (isRanged)
            {
                pos.y += GUITools.singleLineHeight;
                pos.x  = origX;

                labelWidth = 75;
                float w4 = (origW - labelWidth);// * .5f;


                pos.width = labelWidth;
                EditorGUI.LabelField(pos, new GUIContent("Max Value:"));
                pos.x += pos.width;

                pos.width = w4;
                EditorGUI.PropertyField(pos, prop.FindPropertyRelative("rangedMax"), GUITools.noContent);
                pos.x += pos.width;
            }


            if (showAdvanced)
            {
                GUITools.StringFieldWithDefault(origX, pos.y, origW, EditorGUIUtility.singleLineHeight * 3, prop.FindPropertyRelative("description"), "Description...");

                if (Application.isPlaying)
                {
                    pos.x     = origX;
                    pos.y    += GUITools.singleLineHeight * 3;
                    pos.width = origW;

                    GUI.enabled = false;
                    EditorGUI.PropertyField(pos, prop.FindPropertyRelative("baseValue"), true);
                    EditorGUI.PropertyField(pos, prop.FindPropertyRelative("baseValueMultiplyModifier"), true);
                    EditorGUI.PropertyField(pos, prop.FindPropertyRelative("baseValueAdditiveModifier"), true);
                    EditorGUI.PropertyField(pos, prop.FindPropertyRelative("rangedValueModifier"), true);
                    GUI.enabled = true;
                }
            }
            EditorGUI.EndProperty();
        }
Exemplo n.º 8
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            prop = prop.FindPropertyRelative(NeatArrayAttributeDrawer.listName);

            GUITools.Label(pos, label, GUITools.black, GUITools.boldLabel);

            if (GUITools.IconButton(pos.x + pos.width - GUITools.iconButtonWidth, pos.y, new GUIContent("", "Unselect All"), GUITools.red))
            {
                for (int i = 0; i < prop.arraySize; i++)
                {
                    prop.GetArrayElementAtIndex(i).FindPropertyRelative("selected").boolValue = false;
                }
            }

            int indexToDelete = -1;

            float fieldsY = pos.y + GUITools.singleLineHeight;

            Rect fieldRect = new Rect(
                pos.x + GUITools.iconButtonWidth + GUITools.toolbarDividerSize,
                fieldsY,
                pos.width - (GUITools.iconButtonWidth * 3 + GUITools.toolbarDividerSize * 2),
                EditorGUIUtility.singleLineHeight
                );
            Rect colorAreaRect = new Rect(
                pos.x + GUITools.iconButtonWidth,
                fieldsY,
                pos.width - (GUITools.iconButtonWidth * 3),
                GUITools.singleLineHeight
                );

            Rect hoverAreaRect = new Rect(pos.x, fieldsY, pos.width, GUITools.singleLineHeight);

            float selectX = pos.x + pos.width - GUITools.iconButtonWidth;
            float rotateX = selectX - GUITools.iconButtonWidth;

            Rect rotateRect = new Rect(rotateX, fieldsY, GUITools.iconButtonWidth, GUITools.singleLineHeight);


            bool focus = false;

            Event   e        = Event.current;
            Vector2 mousePos = e.mousePosition;

            if (isRotating)
            {
                if (e.type == EventType.MouseUp)
                {
                    isRotating = false;
                    rotateProp = null;
                }
                else if (e.type == EventType.MouseDrag)
                {
                    SerializedProperty rotationProp = rotateProp.FindPropertyRelative("rotation");
                    rotationProp.floatValue = rotationProp.floatValue + e.delta.x;
                }
            }

            else
            {
                if (!LocationPainter.drawing)
                {
                    if ((EventType.KeyUp == e.type || EventType.KeyDown == e.type) && KeyCode.F == e.keyCode)
                    {
                        focus = EventType.KeyUp == e.type;
                        e.Use();
                    }
                }
            }

            for (int i = 0; i < prop.arraySize; i++)
            {
                if (GUITools.IconButton(pos.x, fieldsY, BuiltInIcons.GetIcon("Toolbar Minus", "Delete Element"), GUITools.red))
                {
                    indexToDelete = i;
                }

                SerializedProperty p = prop.GetArrayElementAtIndex(i);

                SerializedProperty hovered = p.FindPropertyRelative("hovered");

                if (!isRotating)
                {
                    hovered.boolValue = false;
                    if (hoverAreaRect.Contains(mousePos))
                    {
                        hovered.boolValue = true;

                        if (focus)
                        {
                            SceneView.lastActiveSceneView.Frame(new Bounds(p.FindPropertyRelative("position").vector3Value, Vector3.one * 3), false);
                        }
                    }
                }

                if (hovered.boolValue)
                {
                    GUITools.Box(colorAreaRect, GUITools.blue);
                }
                else
                {
                    if (p.FindPropertyRelative("isError").boolValue)
                    {
                        GUITools.Box(colorAreaRect, GUITools.red);
                    }
                }

                SerializedProperty nameProp = p.FindPropertyRelative("name");
                if (string.IsNullOrEmpty(nameProp.stringValue))
                {
                    nameProp.stringValue = "SubLcoation_" + i.ToString();
                }
                EditorGUI.PropertyField(fieldRect, nameProp, GUITools.noContent, true);

                GUITools.DrawIconToggle(p.FindPropertyRelative("selected"), new GUIContent("", "Select For Movement"), selectX, fieldsY);

                if (!isRotating)
                {
                    if (Event.current.type == EventType.MouseDown)
                    {
                        if (rotateRect.Contains(mousePos))
                        {
                            hovered.boolValue = true;
                            rotateProp        = p;
                            isRotating        = true;
                        }
                    }
                }
                GUITools.DrawIconToggle(isRotating && hovered.boolValue, rotateGUI, rotateX, fieldsY);


                fieldsY        += GUITools.singleLineHeight;
                fieldRect.y     = fieldsY;
                colorAreaRect.y = fieldsY;
                hoverAreaRect.y = fieldsY;
                rotateRect.y    = fieldsY;
            }

            if (indexToDelete != -1)
            {
                prop.DeleteArrayElementAtIndex(indexToDelete);
            }
        }