Esempio n. 1
0
        public static bool DrawInFoldout(Rect foldoutRect, bool expanded, string header, Action drawStuff)
        {
            expanded = EditorGUI.BeginFoldoutHeaderGroup(foldoutRect, expanded, header);

            if (expanded)
            {
                EditorGUI.indentLevel++;
                drawStuff();
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.EndFoldoutHeaderGroup();

            return(expanded);
        }
Esempio n. 2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            UpdateReflection();

            var startY = position.y;

            position.height = EditorGUIUtility.singleLineHeight;

            expand = EditorGUI.BeginFoldoutHeaderGroup(position, expand, property.name, null, rect => ShowHeaderContextMenu(rect, property));
            if (expand)
            {
                OnExpandedGUI(ref position, property);
            }
            EditorGUI.EndFoldoutHeaderGroup();
            height = position.y + position.height - startY;
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            InitAnimBool(property);

            // EditorGUI.indentLevel--;
            // Debug.Log(position);

            // position = EditorGUI.IndentedRect(position);

            // Debug.Log(position);

            position.x     += 4;
            position.width -= 8;

            position.height = EditorGUIUtility.singleLineHeight;
            var temp = new GUIContent(label);

            SerializedProperty persistentCalls = property.FindPropertyRelative("m_PersistentCalls.m_Calls");

            if (persistentCalls != null)
            {
                temp.text += " (" + persistentCalls.arraySize + ")";
            }

            // visible.target = EditorGUI.Foldout(position, visible.value, temp, true);

#if UNITY_2019_1_OR_NEWER
            var hum = EditorGUIUtility.hierarchyMode;
            EditorGUIUtility.hierarchyMode = false;
            visible.target = EditorGUI.BeginFoldoutHeaderGroup(position, visible.target, temp);
            EditorGUIUtility.hierarchyMode = hum;
#else
            visible.target = EditorGUI.Foldout(position, visible.target, temp, true);
#endif
            if (BlazeDrawerUtil.BeginFade(visible))
            {
                label.text      = null;
                position.height = base.GetPropertyHeight(property, label);
                position.y     += EditorGUIUtility.singleLineHeight;
                base.OnGUI(position, property, label);
            }
            BlazeDrawerUtil.EndFade();
#if UNITY_2019_1_OR_NEWER
            EditorGUI.EndFoldoutHeaderGroup();
#endif
            // EditorGUI.indentLevel++;
        }
Esempio n. 4
0
        void OnGUI()
        {
            _foldout_status = EditorGUI.BeginFoldoutHeaderGroup(new Rect(8, 8, 256, 20), _foldout_status, _foldout_title, null, this.onHeaderAction);

            if (_foldout_status)
            {
                _foldout_title = "Edit Username";

                _username = EditorGUI.TextField(new Rect(8, 28, 256, 20), "User Name", _username);
            }
            else
            {
                _foldout_title = "Input Username";
            }

            EditorGUI.EndFoldoutHeaderGroup();
        }
Esempio n. 5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Rect headerPosition = new Rect
            {
                min  = position.min,
                xMax = position.xMax,
                yMax = position.yMin + EditorGUIUtility.singleLineHeight
            };

            foldout = EditorGUI.BeginFoldoutHeaderGroup(headerPosition, foldout, new GUIContent(property.name));

            if (foldout)
            {
                EditorGUI.indentLevel++;

                var enumType = GetEnumType(property);
                var names    = Enum.GetNames(enumType);

                for (int i = 0; i < names.Length; i++)
                {
                    float yMin          = position.yMin + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * (i + 1);
                    var   labelPosition = new Rect()
                    {
                        xMin = position.xMin,
                        yMin = yMin,
                        xMax = position.xMin + EditorGUIUtility.labelWidth,
                        yMax = yMin + EditorGUIUtility.singleLineHeight
                    };

                    var valuePosition = new Rect()
                    {
                        xMin = position.xMin + EditorGUIUtility.labelWidth,
                        yMin = yMin,
                        xMax = position.xMax,
                        yMax = yMin + EditorGUIUtility.singleLineHeight
                    };

                    EditorGUI.PrefixLabel(labelPosition, new GUIContent(names[i]));
                    EditorGUI.PropertyField(valuePosition, property.FindPropertyRelative("values").GetArrayElementAtIndex(i), new GUIContent());
                }

                EditorGUI.indentLevel--;
            }

            EditorGUI.EndFoldoutHeaderGroup();
        }
Esempio n. 6
0
    private void OnDrawReorderListElement(Rect rect, int index, bool isActive, bool isFocused)
    {
        int length = reordList.serializedProperty.arraySize;

        if (length <= 0)
        {
            return;
        }

        SerializedProperty iteratorProp = reordList.serializedProperty.GetArrayElementAtIndex(index);

        SerializedProperty actionTypeParentProp = iteratorProp.FindPropertyRelative("actionType");
        string             actionName           = actionTypeParentProp.enumDisplayNames[actionTypeParentProp.enumValueIndex];

        Rect labelfoldRect = rect;

        labelfoldRect.height = HeightHeader;
        labelfoldRect.x     += XShiftHeaders;
        labelfoldRect.width -= ShrinkHeaderWidth;

        iteratorProp.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(labelfoldRect, iteratorProp.isExpanded, actionName);

        if (iteratorProp.isExpanded)
        {
            ++EditorGUI.indentLevel;

            SerializedProperty endProp = iteratorProp.GetEndProperty();

            int i = 0;
            while (iteratorProp.NextVisible(true) && !EqualContents(endProp, iteratorProp))
            {
                float multiplier = i == 0 ? AdditionalSpaceMultiplier : 1.0f;
                rect.y     += GetDefaultSpaceBetweenElements() * multiplier;
                rect.height = EditorGUIUtility.singleLineHeight;

                EditorGUI.PropertyField(rect, iteratorProp, true);

                ++i;
            }

            --EditorGUI.indentLevel;
        }

        EditorGUI.EndFoldoutHeaderGroup();
    }
Esempio n. 7
0
        public static bool DrawInFoldout(Rect foldoutRect, bool expanded, string header, Action drawStuff)
        {
            #if UNITY_2019_1_OR_NEWER
            expanded = EditorGUI.BeginFoldoutHeaderGroup(foldoutRect, expanded, header);

            if (expanded)
            {
                EditorGUI.indentLevel++;
                drawStuff();
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.EndFoldoutHeaderGroup();

            return(expanded);
            #endif

            return(false);
        }
Esempio n. 8
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            float labelHeight = GetLabelHeight(label) + Margin;
            var   labelRec    = new Rect(position)
            {
                height = labelHeight
            };
            var eventRec = new Rect(position)
            {
                y      = position.y + labelHeight,
                height = position.height - labelHeight
            };

            property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(labelRec, property.isExpanded, label);
            EditorGUI.EndFoldoutHeaderGroup();
            if (property.isExpanded)
            {
                UnityEventDrawer.OnGUI(eventRec, property, label);
            }
        }
    public static void ShowWeaponParameters(WeaponParameters weaponParameters, float indentValue, ref bool showShootParameters, ref bool showProjectileParameters)
    {
        SerializedObject serializedParameters = new SerializedObject(weaponParameters);

        serializedParameters.Update();

        #region Base Parameters
        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Base Parameters", EditorStyles.boldLabel);

        SerializedProperty weaponNameAttribute = serializedParameters.FindProperty("weaponName");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), weaponNameAttribute);

        SerializedProperty weaponPrefabAttribute = serializedParameters.FindProperty("weaponPrefab");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), weaponPrefabAttribute);
        #endregion

        #region Shoot Parameters
        GUILayout.Space(20);

        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Shoot Parameters", EditorStyles.boldLabel);

        SerializedProperty shootParamsAttribute = serializedParameters.FindProperty("shootParameters");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), shootParamsAttribute);

        serializedParameters.ApplyModifiedProperties();

        ShootParameters shootParams = weaponParameters.GetShootParameters;
        if (shootParams != null)
        {
            showShootParameters = EditorGUI.BeginFoldoutHeaderGroup(EditorStaticMethods.GetIndentedControlRect(indentValue), showShootParameters, (showShootParameters ? "Close" : "Open") + " Shoot Parameters", showShootParameters ? EditorStyles.boldLabel : null);
            EditorGUI.EndFoldoutHeaderGroup();

            if (showShootParameters)
            {
                EditorGUILayout.BeginVertical("box");
                ShootParametersInspector.ShowShootParameters(shootParams, indentValue + 15, ref showProjectileParameters);
                EditorGUILayout.EndVertical();
            }
        }
        #endregion
    }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Validation.

            // Get array property.
            SerializedProperty array = property.FindPropertyRelative("_elements");

            // If Property is not serializable, exit.
            if (array == null)
            {
                return;
            }

            // Setup EnumMatching array to correspond it's enum.
            SetupWithEnums(property, array, out Type enumType);


            // Output below.

            // Foldout label-button.
            position.y         += 3;
            property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(new Rect(position.x, position.y, position.width, 22), property.isExpanded, label);
            EditorGUI.EndFoldoutHeaderGroup();
            position.y += 22;


            // If property is expanded (i.e. foldout opened).
            if (property.isExpanded)
            {
                // Draw each array element.
                string[] enumNames = enumType.GetEnumNames();
                for (int i = 0; i < array.arraySize; i++)
                {
                    // Draw it's self property drawer for property.
                    EditorGUI.PropertyField(position, array.GetArrayElementAtIndex(i), new GUIContent(enumNames[i]), true);
                    position.y += EditorGUI.GetPropertyHeight(array.GetArrayElementAtIndex(i));
                }
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            position.height     = EditorGUIUtility.singleLineHeight;
            property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(position, property.isExpanded, label);

            if (property.isExpanded)
            {
                InitHsvLookup(property);

                Color.RGBToHSV(GetColor(), out float minH, out float minS, out float minV);

                using (new EditorGUI.IndentLevelScope(EditorGUI.indentLevel + 1))
                {
                    DrawHsvProperty(ref position, property, HsvLookup.H, m_hueTexture, 64, 1, 1, ref m_hueTextureS, ref m_hueTextureV);
                    DrawHsvProperty(ref position, property, HsvLookup.S, m_satTexture, 32, minH, Mathf.Max(minV, 0.2f), ref m_satTextureH, ref m_satTextureV);
                    DrawHsvProperty(ref position, property, HsvLookup.V, m_valTexture, 32, minH, minS, ref m_valTextureH, ref m_valTextureS);
                    DrawHsvProperty(ref position, property, HsvLookup.A, m_alphaTexture, 32, 0, 0, ref m_oldAlpha, ref m_oldAlpha);
                }
            }

            EditorGUI.EndFoldoutHeaderGroup();
        }
Esempio n. 12
0
        /// <summary>
        /// Used to draw our element override a bit of the Unity logic in the case
        /// of having no elements.
        /// </summary>
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (_styles == null)
            {
                _styles = new Styles();
            }

            SerializedProperty elements = property.FindPropertyRelative(CALLS_PROPERTY_PATH);
            float heightTemp            = position.height;

            position.height = EditorGUIUtility.singleLineHeight;
            if (!_hasPersistentCalls)
            {
                base.OnGUI(position, property, label);
                position.x    += position.width - BUTTON_SPACING;
                position.width = BUTTON_WIDTH;
                if (GUI.Button(position, _styles.iconToolbarPlus, _styles.preButton))
                {
                    State           state = GetState(property);
                    ReorderableList list  = GetReorderableListFromState(state);
                    list.onAddCallback(list);
                    state.lastSelectedIndex = 0;
                    property.isExpanded     = true;
                }

                return;
            }

            property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(position, property.isExpanded,
                                                                    $"[{elements.arraySize}] {property.displayName} ()");
            position.height = heightTemp;
            if (property.isExpanded)
            {
                base.OnGUI(position, property, label);
            }

            EditorGUI.EndFoldoutHeaderGroup();
        }
Esempio n. 13
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // EditorGUI.BeginProperty(position, label, property);

            EditorGUI.indentLevel++;

            var attr = this.attribute as CollapsedEventAttribute;

            position.height = EditorGUIUtility.singleLineHeight;
            var temp = new GUIContent(label);

            SerializedProperty persistentCalls = property.FindPropertyRelative("m_PersistentCalls.m_Calls");

            if (persistentCalls != null)
            {
                temp.text += " (" + persistentCalls.arraySize + ")";
            }

            attr.visible = EditorGUI.Foldout(position, attr.visible, temp, true);

#if UNITY_2019_1_OR_NEWER
            attr.visible = EditorGUI.BeginFoldoutHeaderGroup(position, attr.visible, temp);
#else
            attr.visible = EditorGUI.Foldout(position, attr.visible, temp, true);
#endif
            if (attr.visible)
            {
                label.text      = null;
                position.height = base.GetPropertyHeight(property, label);
                position.y     += EditorGUIUtility.singleLineHeight;
                base.OnGUI(position, property, label);
            }
#if UNITY_2019_1_OR_NEWER
            EditorGUI.EndFoldoutHeaderGroup();
#endif

            EditorGUI.indentLevel--;
        }
Esempio n. 14
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);

            float lineHeight = EditorGUIUtility.singleLineHeight + 2;
            float start      = position.y;
            var   lineRect   = new Rect(position.x, position.y, position.width, lineHeight);

            lineRect = EditorGUI.IndentedRect(lineRect);

            property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(lineRect, property.isExpanded, property.displayName);

            if (property.isExpanded)
            {
                EditorGUI.indentLevel++;

                lineRect.y += lineHeight;
                EditorGUI.PropertyField(lineRect, property.FindPropertyRelative("hide"));

                var subMeshInfo = property.FindPropertyRelative("subMeshInfo");

                lineRect.y += lineHeight;
                GUI.Label(lineRect, "Submeshes: " + subMeshInfo.arraySize);

                DisplayArray(subMeshInfo, ref lineRect);

                lineRect.y += lineHeight;
                if (GUI.Button(lineRect, "Add Submesh"))
                {
                    ++subMeshInfo.arraySize;
                }

                EditorGUI.indentLevel--;
            }

            EditorGUI.EndFoldoutHeaderGroup();
            EditorGUI.EndProperty();
        }
Esempio n. 15
0
        public override void DrawProperty(ref Rect position, SerializedProperty property)
        {
            base.DrawProperty(ref position, property);

            // FORCES //
            forcesFoldoutGroup = EditorGUI.BeginFoldoutHeaderGroup(new Rect(position.x, GetLineY(), position.width, lineHeight),
                                                                   forcesFoldoutGroup, new GUIContent("Forces"));
            if (forcesFoldoutGroup)
            {
                EditorGUI.indentLevel++;
                DrawForcesGroup(ref position, property);
                EditorGUI.indentLevel--;
            }
            EditorGUI.EndFoldoutHeaderGroup();

            // STUN //
            stunFoldoutGroup = EditorGUI.BeginFoldoutHeaderGroup(new Rect(position.x, GetLineY(), position.width, lineHeight),
                                                                 stunFoldoutGroup, new GUIContent("Stun"));
            if (stunFoldoutGroup)
            {
                EditorGUI.indentLevel++;
                DrawStunGroup(position, property);
                EditorGUI.indentLevel--;
            }
            EditorGUI.EndFoldoutHeaderGroup();

            // DAMAGE //
            damageFoldoutGroup = EditorGUI.BeginFoldoutHeaderGroup(new Rect(position.x, GetLineY(), position.width, lineHeight),
                                                                   damageFoldoutGroup, new GUIContent("Damage"));
            if (damageFoldoutGroup)
            {
                EditorGUI.indentLevel++;
                DrawDamageGroup(position, property);
                EditorGUI.indentLevel--;
            }
            EditorGUI.EndFoldoutHeaderGroup();
        }
Esempio n. 16
0
        private void OnEnable()
        {
            // Get target
            m_target = (AzureTimeController)target;
            m_target.UpdateCalendar();

            // Find the serialized properties
            m_sunTransform     = serializedObject.FindProperty("m_sunTransform");
            m_moonTransform    = serializedObject.FindProperty("m_moonTransform");
            m_directionalLight = serializedObject.FindProperty("m_directionalLight");
            m_followTarget     = serializedObject.FindProperty("m_followTarget");
            m_timeSystem       = serializedObject.FindProperty("m_timeSystem");
            m_timeDirection    = serializedObject.FindProperty("m_timeDirection");
            m_dateLoop         = serializedObject.FindProperty("m_dateLoop");
            m_timeline         = serializedObject.FindProperty("m_timeline");
            m_hour             = serializedObject.FindProperty("m_hour");
            m_minute           = serializedObject.FindProperty("m_minute");
            m_day   = serializedObject.FindProperty("m_day");
            m_month = serializedObject.FindProperty("m_month");
            m_year  = serializedObject.FindProperty("m_year");
            m_selectedCalendarDay = serializedObject.FindProperty("m_selectedCalendarDay");
            m_latitude            = serializedObject.FindProperty("m_latitude");
            m_longitude           = serializedObject.FindProperty("m_longitude");
            m_utc                    = serializedObject.FindProperty("m_utc");
            m_dayLength              = serializedObject.FindProperty("m_dayLength");
            m_minLightAltitude       = serializedObject.FindProperty("m_minLightAltitude");
            m_isTimeEvaluatedByCurve = serializedObject.FindProperty("m_isTimeEvaluatedByCurve");
            m_dayLengthCurve         = serializedObject.FindProperty("m_dayLengthCurve");
            m_celestialBodiesList    = serializedObject.FindProperty("m_celestialBodiesList");
            m_onMinuteChange         = serializedObject.FindProperty("m_onMinuteChange");
            m_onHourChange           = serializedObject.FindProperty("m_onHourChange");
            m_onDayChange            = serializedObject.FindProperty("m_onDayChange");
            m_customEventScanMode    = serializedObject.FindProperty("m_customEventScanMode");
            m_customEventList        = serializedObject.FindProperty("m_customEventList");
            m_dayNumberList          = serializedObject.FindProperty("m_dayNumberList");

            // Create celestial body list
            m_reorderableCelestialBodiesList = new ReorderableList(serializedObject, m_celestialBodiesList, true, true, true, true)
            {
                drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    rect.y += 2;
                    float half      = rect.width / 2;
                    Rect  fieldRect = new Rect(rect.x, rect.y, half, EditorGUIUtility.singleLineHeight);

                    var element   = m_celestialBodiesList.GetArrayElementAtIndex(index);
                    var transform = element.FindPropertyRelative("transform");
                    var type      = element.FindPropertyRelative("type");

                    // Celestial body transform
                    EditorGUI.PropertyField(fieldRect, transform, GUIContent.none);

                    // Celestial body type
                    fieldRect = new Rect(rect.x + half + 5, rect.y, half - 5, EditorGUIUtility.singleLineHeight);
                    EditorGUI.PropertyField(fieldRect, type, GUIContent.none);
                },

                drawHeaderCallback = (Rect rect) =>
                {
                    EditorGUI.LabelField(rect, "Celestial Bodies", EditorStyles.boldLabel);
                },

                drawElementBackgroundCallback = (rect, index, active, focused) =>
                {
                    if (active)
                    {
                        GUI.Box(new Rect(rect.x + 2, rect.y, rect.width - 4, rect.height + 1), "", "selectionRect");
                    }
                }
            };

            // Create custom event list
            m_reorderableCeustomEventList = new ReorderableList(serializedObject, m_customEventList, true, true, true, true)
            {
                drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    rect.y += 2;
                    var height  = EditorGUIUtility.singleLineHeight;
                    var element = m_customEventList.GetArrayElementAtIndex(index);

                    element.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(new Rect(rect.x + 13, rect.y, rect.width - 17, height), element.isExpanded, "Event " + index.ToString());
                    if (element.isExpanded)
                    {
                        // Date settings
                        rect.y += height + 6;
                        var month  = element.FindPropertyRelative("month");
                        var day    = element.FindPropertyRelative("day");
                        var year   = element.FindPropertyRelative("year");
                        var hour   = element.FindPropertyRelative("hour");
                        var minute = element.FindPropertyRelative("minute");

                        m_eventDateSelector[0] = month.intValue;
                        m_eventDateSelector[1] = day.intValue;
                        m_eventDateSelector[2] = year.intValue;
                        EditorGUI.MultiIntField(new Rect(rect.x, rect.y, rect.width, height), m_dateSelectorContent, m_eventDateSelector);
                        month.intValue = m_eventDateSelector[0];
                        day.intValue   = m_eventDateSelector[1];
                        year.intValue  = m_eventDateSelector[2];

                        // Time settings
                        rect.y += height + 4;
                        m_eventTimeSelector[0] = hour.intValue;
                        m_eventTimeSelector[1] = minute.intValue;
                        EditorGUI.MultiIntField(new Rect(rect.x, rect.y, rect.width, height), m_timeSelectorContent, m_eventTimeSelector);
                        hour.intValue   = m_eventTimeSelector[0];
                        minute.intValue = m_eventTimeSelector[1];

                        // UnityEvent list
                        rect.y += height + 4;
                        EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, height), element.FindPropertyRelative("unityEvent"), new GUIContent("Unity Event", ""));
                    }
                    EditorGUI.EndFoldoutHeaderGroup();
                },

                drawHeaderCallback = (Rect rect) =>
                {
                    EditorGUI.LabelField(rect, "Custom Events", EditorStyles.boldLabel);
                },

                elementHeightCallback = (int index) =>
                {
                    var element       = m_customEventList.GetArrayElementAtIndex(index);
                    var elementHeight = EditorGUI.GetPropertyHeight(element);
                    var margin        = EditorGUIUtility.standardVerticalSpacing + 2;
                    if (element.isExpanded)
                    {
                        return(elementHeight - 40);
                    }
                    else
                    {
                        return(elementHeight + margin);
                    }
                },

                drawElementBackgroundCallback = (rect, index, active, focused) =>
                {
                    if (active)
                    {
                        GUI.Box(new Rect(rect.x + 2, rect.y, rect.width - 4, rect.height + 1), "", "selectionRect");
                    }
                }
            };
        }
Esempio n. 17
0
        public override void OnInspectorGUI()
        {
            // Start custom inspector
            serializedObject.Update();
            EditorGUI.BeginChangeCheck();


            // References header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_referencesHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_referencesHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_referencesHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" References", ""));
            if (m_referencesHeaderGroup.isExpanded)
            {
                EditorGUILayout.Space(2);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_sunTransform);
                EditorGUILayout.PropertyField(m_moonTransform);
                EditorGUILayout.PropertyField(m_skyMaterial);
                EditorGUILayout.PropertyField(m_fogMaterial);
                EditorGUILayout.PropertyField(m_emptySkyShader);
                EditorGUILayout.PropertyField(m_staticCloudsShader);
                EditorGUILayout.PropertyField(m_dynamicCloudsShader);
                EditorGUILayout.PropertyField(m_sunTexture);
                EditorGUILayout.PropertyField(m_moonTexture);
                EditorGUILayout.PropertyField(m_starfieldTexture);
                EditorGUILayout.PropertyField(m_dynamicCloudsTexture);
                EditorGUILayout.PropertyField(m_staticCloudTexture);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);

            // Scattering header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_scatteringHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_scatteringHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_scatteringHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" Scattering", ""));
            if (m_scatteringHeaderGroup.isExpanded)
            {
                EditorGUILayout.Space(2);
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(m_molecularDensity, 0.1f, 3.0f);
                EditorGUILayout.Slider(m_wavelengthR, 380f, 740f);
                EditorGUILayout.Slider(m_wavelengthG, 380f, 740f);
                EditorGUILayout.Slider(m_wavelengthB, 380f, 740f);
                EditorGUILayout.Slider(m_kr, 0f, 20f);
                EditorGUILayout.Slider(m_km, 0f, 10f);
                EditorGUILayout.Slider(m_rayleigh, 0f, 5f);
                EditorGUILayout.Slider(m_mie, 0f, 5f);
                EditorGUILayout.Slider(m_mieDistance, 0f, 1f);
                EditorGUILayout.Slider(m_scattering, 0f, 1f);
                EditorGUILayout.Slider(m_luminance, 0f, 5f);
                EditorGUILayout.Slider(m_exposure, 0f, 10f);
                EditorGUILayout.PropertyField(m_rayleighColor);
                EditorGUILayout.PropertyField(m_mieColor);
                EditorGUILayout.PropertyField(m_scatteringColor);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);

            // Outer space header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_outerSpaceHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_outerSpaceHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_outerSpaceHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" Outer Space", ""));
            if (m_outerSpaceHeaderGroup.isExpanded)
            {
                EditorGUILayout.Space(2);
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(m_sunTextureSize, 0.5f, 10f);
                EditorGUILayout.Slider(m_sunTextureIntensity, 0f, 2f);
                EditorGUILayout.PropertyField(m_sunTextureColor);
                EditorGUILayout.Slider(m_moonTextureSize, 1f, 20f);
                EditorGUILayout.Slider(m_moonTextureIntensity, 0f, 2f);
                EditorGUILayout.PropertyField(m_moonTextureColor);
                EditorGUILayout.Slider(m_starsIntensity, 0f, 1f);
                EditorGUILayout.Slider(m_milkyWayIntensity, 0f, 1f);
                EditorGUILayout.PropertyField(m_starfieldColor);
                EditorGUILayout.Slider(m_starfieldRotationX, -180f, 180f);
                EditorGUILayout.Slider(m_starfieldRotationY, -180f, 180f);
                EditorGUILayout.Slider(m_starfieldRotationZ, -180f, 180f);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);

            // Fog Scattering header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_fogScatteringHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_fogScatteringHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_fogScatteringHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" Fog Scattering", ""));
            if (m_fogScatteringHeaderGroup.isExpanded)
            {
                EditorGUILayout.Space(2);
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(m_fogScatteringScale, 0f, 1f);
                EditorGUILayout.Slider(m_globalFogDistance, 0f, 25000f);
                EditorGUILayout.Slider(m_globalFogSmoothStep, -1f, 2f);
                EditorGUILayout.Slider(m_globalFogDensity, 0f, 1f);
                EditorGUILayout.Slider(m_heightFogDistance, 0f, 1500f);
                EditorGUILayout.Slider(m_heightFogSmoothStep, -1f, 2f);
                EditorGUILayout.Slider(m_heightFogDensity, 0f, 1f);
                EditorGUILayout.Slider(m_heightFogStart, -500f, 500f);
                EditorGUILayout.Slider(m_heightFogEnd, 0f, 2500f);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);

            // Clouds header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_cloudsHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_cloudsHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_cloudsHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" Clouds", ""));
            if (m_cloudsHeaderGroup.isExpanded)
            {
                EditorGUILayout.Space(2);
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(m_dynamicCloudsAltitude, 1f, 20f);
                EditorGUILayout.Slider(m_dynamicCloudsDirection, 0f, 1f);
                EditorGUILayout.Slider(m_dynamicCloudsSpeed, 0f, 1f);
                EditorGUILayout.Slider(m_dynamicCloudsDensity, 0f, 1f);
                EditorGUILayout.PropertyField(m_dynamicCloudsColor1);
                EditorGUILayout.PropertyField(m_dynamicCloudsColor2);
                EditorGUILayout.Slider(staticCloudLayer1Speed, 0f, 0.01f);
                EditorGUILayout.Slider(staticCloudLayer2Speed, 0f, 0.01f);
                EditorGUILayout.Slider(staticCloudScattering, 0f, 2f);
                EditorGUILayout.Slider(staticCloudExtinction, 1f, 5f);
                EditorGUILayout.Slider(staticCloudSaturation, 1f, 8f);
                EditorGUILayout.Slider(staticCloudOpacity, 0f, 2f);
                EditorGUILayout.PropertyField(staticCloudColor);


                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);

            // Options header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_optionsHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_optionsHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_optionsHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" Options", ""));
            if (m_optionsHeaderGroup.isExpanded)
            {
                EditorGUILayout.Space(2);
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_shaderUpdateMode);
                EditorGUILayout.PropertyField(m_scatteringMode);
                EditorGUILayout.PropertyField(m_cloudMode);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);


            // Update the inspector when there is a change
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                m_target.UpdateSkySettings();
            }
        }
Esempio n. 18
0
        public override void OnInspectorGUI()
        {
            // Start custom inspector
            serializedObject.Update();
            EditorGUI.BeginChangeCheck();

            // References header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_referencesHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_referencesHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_referencesHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" References", ""));
            if (m_referencesHeaderGroup.isExpanded)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(m_windZone);
                EditorGUILayout.PropertyField(m_lightRainAudioSource);
                EditorGUILayout.PropertyField(m_mediumRainAudioSource);
                EditorGUILayout.PropertyField(m_heavyRainAudioSource);
                EditorGUILayout.PropertyField(m_lightWindAudioSource);
                EditorGUILayout.PropertyField(m_mediumWindAudioSource);
                EditorGUILayout.PropertyField(m_heavyWindAudioSource);
                EditorGUILayout.PropertyField(m_defaultRainMaterial);
                EditorGUILayout.PropertyField(m_heavyRainMaterial);
                EditorGUILayout.PropertyField(m_snowMaterial);
                EditorGUILayout.PropertyField(m_rippleMaterial);
                EditorGUILayout.PropertyField(m_lightRainParticle);
                EditorGUILayout.PropertyField(m_mediumRainParticle);
                EditorGUILayout.PropertyField(m_heavyRainParticle);
                EditorGUILayout.PropertyField(m_snowParticle);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);

            // Settings header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_settingsHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_settingsHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_settingsHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" Settings", ""));
            if (m_settingsHeaderGroup.isExpanded)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.Slider(m_lightRainIntensity, 0f, 1f);
                EditorGUILayout.Slider(m_mediumRainIntensity, 0f, 1f);
                EditorGUILayout.Slider(m_heavyRainIntensity, 0f, 1f);
                EditorGUILayout.Slider(m_snowIntensity, 0f, 1f);
                EditorGUILayout.PropertyField(m_rainColor);
                EditorGUILayout.PropertyField(m_snowColor);
                EditorGUILayout.Slider(m_lightRainSoundFx, 0f, 1f);
                EditorGUILayout.Slider(m_mediumRainSoundFx, 0f, 1f);
                EditorGUILayout.Slider(m_heavyRainSoundFx, 0f, 1f);
                EditorGUILayout.Slider(m_lightWindSoundFx, 0f, 1f);
                EditorGUILayout.Slider(m_mediumWindSoundFx, 0f, 1f);
                EditorGUILayout.Slider(m_heavyWindSoundFx, 0f, 1f);
                EditorGUILayout.Slider(m_windSpeed, 0f, 1f);
                EditorGUILayout.Slider(m_windDirection, 0f, 1f);
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);

            // Settings header group
            m_controlRect = EditorGUILayout.GetControlRect();
            m_headerRect  = new Rect(m_controlRect.x + 15, m_controlRect.y, m_controlRect.width - 20, EditorGUIUtility.singleLineHeight);
            m_thunderSeetingsHeaderGroup.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(m_headerRect, m_thunderSeetingsHeaderGroup.isExpanded, GUIContent.none, "RL Header");
            EditorGUI.Foldout(m_headerRect, m_thunderSeetingsHeaderGroup.isExpanded, GUIContent.none);
            EditorGUI.LabelField(m_headerRect, new GUIContent(" Thunder Settings", ""));
            if (m_thunderSeetingsHeaderGroup.isExpanded)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.Space();
                m_reorderableThunderList.DoLayoutList();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFoldoutHeaderGroup();
            EditorGUILayout.Space(2);

            // Update the inspector when there is a change
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Esempio n. 19
0
    protected virtual bool DrawListHeader(Rect rect, ReorderableList list)
    {
        const int sizeWidth    = 24;
        const int buttonsWidth = 54;

        var property = list.serializedProperty;

        rect.xMin  += 16;
        rect.yMin  += 1;
        rect.height = EditorGUIUtility.singleLineHeight;

        var foldoutRect = new Rect(rect);

        foldoutRect.width  -= buttonsWidth + sizeWidth;
        foldoutRect.height -= 1;

        if (foldoutHeader == null)
        {
            foldoutHeader = new GUIStyle(EditorStyles.foldoutHeader)
            {
                richText    = true, fontStyle = FontStyle.Normal, clipping = TextClipping.Clip,
                fixedHeight = 0, padding = new RectOffset(14, 5, 2, 2),
            }
        }
        ;

        // Header
        {
            var eventParams = (string)GetEventParams.Invoke(null, new[] { m_DummyEvent });
            var hex         = EditorGUIUtility.isProSkin ? "ffffff" : "000000";
            var text        = (string.IsNullOrEmpty(m_Text) ? "Event" : m_Text) + $"<color=#{hex}70>{eventParams}</color>";

            property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(foldoutRect, property.isExpanded, text, foldoutHeader);
            EditorGUI.EndFoldoutHeaderGroup();
        }

        var sizeRect = new Rect(rect)
        {
            x = foldoutRect.xMax, width = sizeWidth
        };

        sizeRect.yMin   += 1;
        sizeRect.height -= 1;

        // Size field
        {
            EditorGUI.BeginChangeCheck();
            var numberField = EditorStyles.numberField;
            numberField.contentOffset = new Vector2(0, -1);

            var arraySize = EditorGUI.IntField(sizeRect, property.arraySize);

            numberField.contentOffset = Vector2.zero;
            if (EditorGUI.EndChangeCheck())
            {
                property.arraySize = arraySize;
            }
        }

        var footerRect = new Rect(rect)
        {
            x = sizeRect.xMax + 12, width = buttonsWidth
        };

        footerRect.yMin += 1;

        // Footer buttons
        {
            var footerBg = ReorderableList.defaultBehaviours.footerBackground;
            footerBg.fixedHeight = 0.01f;

            ReorderableList.defaultBehaviours.DrawFooter(footerRect, list);

            footerBg.fixedHeight = 0;
        }

        return(property.isExpanded);
    }
Esempio n. 20
0
        public void Draw(Rect r, Rect visibleArea)
        {
            var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();

            m_IsNotInPrefabContextModeWithOverrides = prefabStage == null || prefabStage.mode != PrefabStage.Mode.InContext || !PrefabStage.s_PatchAllOverriddenProperties ||
                                                      Selection.objects.All(obj => PrefabUtility.IsPartOfAnyPrefab(obj) && !AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)).Equals(AssetDatabase.AssetPathToGUID(prefabStage.assetPath)));
            m_ReorderableList.draggable = m_Reorderable && m_IsNotInPrefabContextModeWithOverrides;

            Rect headerRect = new Rect(r.x, r.y, r.width, m_HeaderHeight);
            Rect sizeRect   = new Rect(headerRect.xMax - Constants.kArraySizeWidth, headerRect.y,
                                       Constants.kArraySizeWidth, m_HeaderHeight);

            EventType prevType = Event.current.type;

            if (Event.current.type == EventType.MouseUp && sizeRect.Contains(Event.current.mousePosition))
            {
                Event.current.type = EventType.Used;
            }

            EditorGUI.BeginChangeCheck();
            m_Foldout = EditorGUI.BeginFoldoutHeaderGroup(headerRect, m_Foldout, m_Header);
            EditorGUI.EndFoldoutHeaderGroup();
            if (EditorGUI.EndChangeCheck())
            {
                m_ReorderableList.ClearCacheRecursive();
            }

            if (Event.current.type == EventType.Used && sizeRect.Contains(Event.current.mousePosition))
            {
                Event.current.type = prevType;
            }

            EditorGUI.DefaultPropertyField(sizeRect, m_ArraySize, GUIContent.none);
            EditorGUI.LabelField(sizeRect, new GUIContent("", "Array Size"));

            if (headerRect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)
                {
                    Object[] objReferences = DragAndDrop.objectReferences;
                    foreach (var o in objReferences)
                    {
                        if (EditorGUI.ValidateObjectFieldAssignment(new[] { o }, typeof(Object), m_ReorderableList.serializedProperty,
                                                                    EditorGUI.ObjectFieldValidatorOptions.None) != null)
                        {
                            DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                        }
                        else
                        {
                            continue;
                        }

                        if (Event.current.type == EventType.DragPerform)
                        {
                            ReorderableList.defaultBehaviours.DoAddButton(m_ReorderableList, o);
                        }
                    }
                    DragAndDrop.AcceptDrag();
                    Event.current.Use();
                }
            }

            if (Event.current.type == EventType.DragExited)
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.None;
                Event.current.Use();
            }

            if (m_Foldout)
            {
                r.y      += m_HeaderHeight + Constants.kHeaderPadding;
                r.height -= m_HeaderHeight + Constants.kHeaderPadding;

                visibleArea.y -= r.y;
                m_ReorderableList.DoList(r, visibleArea);
            }
        }
Esempio n. 21
0
        private void OnEnable()
        {
            // Get target
            m_target = (AzureWeatherController)target;
            m_target.RefreshOverrideTargets();
            instance = this;

            // Get serialized properties
            m_azureTimeController            = serializedObject.FindProperty("m_azureTimeController");
            m_defaultWeatherTransitionLength = serializedObject.FindProperty("m_defaultWeatherTransitionLength");
            m_defaultWeatherProfilesList     = serializedObject.FindProperty("m_defaultWeatherProfilesList");
            m_weatherTransitionProgress      = serializedObject.FindProperty("m_weatherTransitionProgress");
            m_globalWeatherProfilesList      = serializedObject.FindProperty("m_globalWeatherProfilesList");
            m_localWeatherZoneTrigger        = serializedObject.FindProperty("m_localWeatherZoneTrigger");
            m_localWeatherZonesList          = serializedObject.FindProperty("m_localWeatherZonesList");
            m_overrideObject       = serializedObject.FindProperty("overrideObject");
            m_overridePropertyList = serializedObject.FindProperty("m_overridePropertyList");
            m_timeOfDay            = serializedObject.FindProperty("m_timeOfDay");
            m_sunElevation         = serializedObject.FindProperty("m_sunElevation");
            m_moonElevation        = serializedObject.FindProperty("m_moonElevation");

            // Create the default weather reorderable lists
            m_defaultWeatherProfilesReorderableList = new ReorderableList(serializedObject, m_defaultWeatherProfilesList, true, true, true, true)
            {
                drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    rect.y += 2;
                    Rect fieldRect = new Rect(rect.x + 65, rect.y, rect.width - 65, EditorGUIUtility.singleLineHeight);

                    // Profile index
                    EditorGUI.LabelField(rect, "Profile " + index.ToString());

                    // Object field
                    var element = m_defaultWeatherProfilesList.GetArrayElementAtIndex(index);
                    EditorGUI.PropertyField(fieldRect, element, GUIContent.none);
                },

                drawHeaderCallback = (Rect rect) =>
                {
                    EditorGUI.LabelField(rect, "Default Weather Profiles", EditorStyles.boldLabel);
                },

                drawElementBackgroundCallback = (rect, index, active, focused) =>
                {
                    if (active)
                    {
                        GUI.Box(new Rect(rect.x + 2, rect.y, rect.width - 4, rect.height + 1), "", "selectionRect");
                    }
                }
            };

            // Create the global weather reorderable lists
            m_globalWeatherProfilesReorderableList = new ReorderableList(serializedObject, m_globalWeatherProfilesList, true, true, true, true)
            {
                drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    rect.y += 2;
                    Rect fieldRect  = new Rect(rect.x + 65, rect.y, rect.width - 131, EditorGUIUtility.singleLineHeight);
                    var  element    = m_globalWeatherProfilesList.GetArrayElementAtIndex(index);
                    var  profile    = element.FindPropertyRelative("profile");
                    var  transition = element.FindPropertyRelative("transitionLength");

                    // Profile index
                    EditorGUI.LabelField(rect, "Profile  " + index.ToString());

                    // Object field
                    EditorGUI.PropertyField(fieldRect, profile, GUIContent.none);

                    // Transition time field
                    fieldRect = new Rect(rect.width - 25, rect.y, 32, EditorGUIUtility.singleLineHeight);
                    EditorGUI.PropertyField(fieldRect, transition, GUIContent.none);

                    // Go button
                    fieldRect = new Rect(rect.x + rect.width - 30, rect.y, 30, EditorGUIUtility.singleLineHeight);
                    if (GUI.Button(fieldRect, "Go"))
                    {
                        if (Application.isPlaying)
                        {
                            m_target.SetNewWeatherProfile(index);
                        }
                        else
                        {
                            Debug.Log("To perform a weather transition, the application must be playing.");
                        }
                    }
                },

                onAddCallback = (ReorderableList l) =>
                {
                    ReorderableList.defaultBehaviours.DoAddButton(l);

                    var element = l.serializedProperty.GetArrayElementAtIndex(l.index);
                    element.FindPropertyRelative("transitionLength").floatValue = 10.0f;
                },

                drawElementBackgroundCallback = (rect, index, active, focused) =>
                {
                    if (active)
                    {
                        GUI.Box(new Rect(rect.x + 2, rect.y, rect.width - 4, rect.height + 1), "", "selectionRect");
                    }
                }
            };

            // Create the local weather zones list
            m_localWeatherZonesReorderableList = new ReorderableList(serializedObject, m_localWeatherZonesList, true, true, true, true)
            {
                drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    rect.y += 2;
                    Rect fieldRect = new Rect(rect.x + 65, rect.y, rect.width - 65, EditorGUIUtility.singleLineHeight);

                    // Profile index
                    EditorGUI.LabelField(rect, "Priority " + index.ToString());

                    // Object field
                    EditorGUI.PropertyField(fieldRect, m_localWeatherZonesList.GetArrayElementAtIndex(index), GUIContent.none);
                },

                drawElementBackgroundCallback = (rect, index, active, focused) =>
                {
                    if (active)
                    {
                        GUI.Box(new Rect(rect.x + 2, rect.y, rect.width - 4, rect.height + 1), "", "selectionRect");
                    }
                }
            };

            // Create the override properties reorderable lists
            m_overridePropertyReorderableList = new ReorderableList(serializedObject, m_overridePropertyList, false, true, false, false)
            {
                drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    float height    = EditorGUIUtility.singleLineHeight;
                    Rect  fieldRect = new Rect(rect.x + 15, rect.y, rect.width - 18, height);
                    var   element   = m_overridePropertyList.GetArrayElementAtIndex(index);

                    var name        = element.FindPropertyRelative("name");
                    var description = element.FindPropertyRelative("description");
                    name.stringValue        = m_target.overrideObject.customPropertyList[index].name;
                    description.stringValue = m_target.overrideObject.customPropertyList[index].description;

                    // Create inner reorderable list
                    var             innerList = element.FindPropertyRelative("overridePropertySetupList");
                    string          listKey   = element.propertyPath;
                    ReorderableList innerReorderableList;

                    if (m_innerListDict.ContainsKey(listKey))
                    {
                        innerReorderableList = m_innerListDict[listKey];
                    }
                    else
                    {
                        innerReorderableList = new ReorderableList(element.serializedObject, innerList, true, true, true, true)
                        {
                            drawElementCallback = (Rect innerRect, int innerIndex, bool innerIsActive, bool innerIsFocused) =>
                            {
                                if (element.isExpanded)
                                {
                                    float half         = innerRect.width / 2;
                                    var   innerElement = innerList.GetArrayElementAtIndex(innerIndex);

                                    // Override type
                                    var targetType = innerElement.FindPropertyRelative("targetType");
                                    fieldRect = new Rect(innerRect.x, innerRect.y, innerRect.width, height);
                                    EditorGUI.LabelField(fieldRect, "Target Type");
                                    fieldRect = new Rect(innerRect.x + half, innerRect.y, innerRect.width - half, height);
                                    EditorGUI.PropertyField(fieldRect, targetType, GUIContent.none);

                                    if (targetType.enumValueIndex == 0 || targetType.enumValueIndex == 1)
                                    {
                                        // Object field
                                        var gameObject = innerElement.FindPropertyRelative("targetGameObject");
                                        fieldRect = new Rect(innerRect.x, innerRect.y + height + 2f, innerRect.width, height);
                                        EditorGUI.LabelField(fieldRect, "Game Object");
                                        GUI.color = gameObject.objectReferenceValue ? m_greenColor : m_redColor;
                                        fieldRect = new Rect(innerRect.x + half, innerRect.y + height + 2f, innerRect.width - half, height);
                                        EditorGUI.PropertyField(fieldRect, gameObject, GUIContent.none);
                                        GUI.color = Color.white;

                                        // Component name field
                                        var targetComponent = innerElement.FindPropertyRelative("targetComponent");
                                        var componentName   = innerElement.FindPropertyRelative("targetComponentName");
                                        fieldRect = new Rect(innerRect.x, innerRect.y + height * 2f + 4f, innerRect.width, height);
                                        EditorGUI.LabelField(fieldRect, "Component Name");
                                        GUI.color = gameObject.objectReferenceValue && targetComponent.objectReferenceValue ? m_greenColor : m_redColor;
                                        fieldRect = new Rect(innerRect.x + half, innerRect.y + height * 2f + 4f, innerRect.width - half, height);
                                        componentName.stringValue = EditorGUI.DelayedTextField(fieldRect, GUIContent.none, componentName.stringValue);
                                        GUI.color = Color.white;

                                        // Property name field
                                        var propertyName   = innerElement.FindPropertyRelative("targetPropertyName");
                                        var targetField    = innerElement.FindPropertyRelative("targetField");
                                        var targetProperty = innerElement.FindPropertyRelative("targetProperty");
                                        fieldRect = new Rect(innerRect.x, innerRect.y + height * 3f + 6f, innerRect.width, height);
                                        EditorGUI.LabelField(fieldRect, "Property Name");
                                        GUI.color = m_greenColor;
                                        if (targetType.enumValueIndex == 0 && m_target.TargetHasField(index, innerIndex))
                                        {
                                            GUI.color = m_redColor;
                                        }
                                        if (targetType.enumValueIndex == 1 && m_target.TargetHasProperty(index, innerIndex))
                                        {
                                            GUI.color = m_redColor;
                                        }
                                        fieldRect = new Rect(innerRect.x + half, innerRect.y + height * 3f + 6f, innerRect.width - half, height);
                                        propertyName.stringValue = EditorGUI.DelayedTextField(fieldRect, GUIContent.none, propertyName.stringValue);
                                        GUI.color = Color.white;
                                    }

                                    if (targetType.enumValueIndex == 2)
                                    {
                                        // Shader update mode
                                        var targetShaderUpdateMode = innerElement.FindPropertyRelative("targetShaderUpdateMode");
                                        fieldRect = new Rect(innerRect.x, innerRect.y + height + 2f, innerRect.width, height);
                                        EditorGUI.LabelField(fieldRect, "Shader Update Mode");
                                        fieldRect = new Rect(innerRect.x + half, innerRect.y + height + 2f, innerRect.width - half, height);
                                        EditorGUI.PropertyField(fieldRect, targetShaderUpdateMode, GUIContent.none);

                                        if (targetShaderUpdateMode.enumValueIndex == 0)
                                        {
                                            // Material field
                                            var material = innerElement.FindPropertyRelative("targetMaterial");
                                            fieldRect = new Rect(innerRect.x, innerRect.y + height * 2f + 4f, innerRect.width, height);
                                            EditorGUI.LabelField(fieldRect, "Material");
                                            GUI.color = material.objectReferenceValue ? m_greenColor : m_redColor;
                                            fieldRect = new Rect(innerRect.x + half, innerRect.y + height * 2f + 4f, innerRect.width - half, height);
                                            EditorGUI.PropertyField(fieldRect, material, GUIContent.none);
                                            GUI.color = Color.white;
                                        }
                                        else
                                        {
                                            fieldRect = new Rect(innerRect.x, innerRect.y + height * 2f + 4f, innerRect.width, height);
                                            EditorGUI.LabelField(fieldRect, "Setting a global value to all shaders using this property!", EditorStyles.helpBox);
                                        }

                                        // Shader uniform name field
                                        var propertyName = innerElement.FindPropertyRelative("targetPropertyName");
                                        fieldRect = new Rect(innerRect.x, innerRect.y + height * 3f + 6f, innerRect.width, height);
                                        EditorGUI.LabelField(fieldRect, "Property Name");
                                        fieldRect = new Rect(innerRect.x + half, innerRect.y + height * 3f + 6f, innerRect.width - half, height);
                                        propertyName.stringValue = EditorGUI.DelayedTextField(fieldRect, GUIContent.none, propertyName.stringValue);

                                        var targetUniformID = innerElement.FindPropertyRelative("targetUniformID");
                                        targetUniformID.intValue = Shader.PropertyToID(propertyName.stringValue);
                                    }

                                    // Multiplier field
                                    var multiplier = innerElement.FindPropertyRelative("multiplier");
                                    fieldRect = new Rect(innerRect.x, innerRect.y + height * 4f + 8f, innerRect.width, height);
                                    EditorGUI.LabelField(fieldRect, "Multiplier");
                                    fieldRect = new Rect(innerRect.x + half, innerRect.y + height * 4f + 8f, innerRect.width - half, height);
                                    EditorGUI.PropertyField(fieldRect, multiplier, GUIContent.none);
                                }
                            },

                            onAddCallback = (ReorderableList l) =>
                            {
                                ReorderableList.defaultBehaviours.DoAddButton(l);
                                var innerElement = l.serializedProperty.GetArrayElementAtIndex(l.index);
                                innerElement.FindPropertyRelative("multiplier").floatValue = 1.0f;
                            },

                            drawHeaderCallback = (Rect innerRect) =>
                            {
                                Rect r = new Rect(innerRect.x + 8, innerRect.y - 1, innerRect.width - 6, innerRect.height + 2);
                                element.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(r, element.isExpanded, GUIContent.none, "RL Header");
                                EditorGUI.EndFoldoutHeaderGroup();
                                EditorGUI.Foldout(r, element.isExpanded, GUIContent.none);
                                EditorGUI.LabelField(r, new GUIContent(" " + index + " - " + name.stringValue, description.stringValue));
                            },

                            elementHeightCallback = (int innerIndex) => { return(EditorGUIUtility.singleLineHeight * 6); },

                            drawElementBackgroundCallback = (innerRect, innerIndex, innerIsActive, innerIsFocused) =>
                            {
                                if (innerIsActive && element.isExpanded)
                                {
                                    GUI.Box(new Rect(innerRect.x + 2, innerRect.y - 3, innerRect.width - 4, innerRect.height), "", "selectionRect");
                                }
                            }
                        };
                    }

                    m_innerListDict[listKey] = innerReorderableList;

                    if (element.isExpanded)
                    {
                        innerReorderableList.DoList(rect);
                    }
                    else
                    {
                        Rect r = new Rect(rect.x + 14, rect.y, rect.width - 18, rect.height);
                        element.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(r, element.isExpanded, GUIContent.none, "RL Header");
                        EditorGUI.EndFoldoutHeaderGroup();
                        r.y -= 2;
                        EditorGUI.Foldout(r, element.isExpanded, GUIContent.none);
                        EditorGUI.LabelField(r, new GUIContent(" " + index + " - " + name.stringValue, description.stringValue));
                    }
                },

                elementHeightCallback = (int index) =>
                {
                    var   element   = m_overridePropertyReorderableList.serializedProperty.GetArrayElementAtIndex(index);
                    var   margin    = EditorGUIUtility.standardVerticalSpacing + 3f;
                    var   innerList = element.FindPropertyRelative("overridePropertySetupList");
                    float h         = EditorGUIUtility.singleLineHeight;
                    if (element.isExpanded)
                    {
                        return(Mathf.Max(100, (h * 6) * (innerList.arraySize + 1) - 50));
                    }
                    else
                    {
                        return(h + margin);
                    }
                },

                drawElementBackgroundCallback = (rect, index, active, focused) => { }
            };
        }
Esempio n. 22
0
        public void Draw(GUIContent label, Rect r, Rect visibleArea, string tooltip, bool includeChildren)
        {
            r.xMin += EditorGUI.indent;
            var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();

            m_IsNotInPrefabContextModeWithOverrides = prefabStage == null || prefabStage.mode != PrefabStage.Mode.InContext || !PrefabStage.s_PatchAllOverriddenProperties ||
                                                      Selection.objects.All(obj => PrefabUtility.IsPartOfAnyPrefab(obj) && !AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(obj)).Equals(AssetDatabase.AssetPathToGUID(prefabStage.assetPath)));
            m_ReorderableList.draggable = m_Reorderable && m_IsNotInPrefabContextModeWithOverrides;

            Rect headerRect = new Rect(r.x, r.y, r.width, m_HeaderHeight);
            Rect sizeRect   = new Rect(headerRect.xMax - Constants.kArraySizeWidth - EditorGUI.indent * EditorGUI.indentLevel, headerRect.y,
                                       Constants.kArraySizeWidth + EditorGUI.indent * EditorGUI.indentLevel, m_HeaderHeight);

            Event     evt      = Event.current;
            EventType prevType = evt.type;

            if (!string.IsNullOrEmpty(tooltip) && prevType == EventType.Repaint)
            {
                bool hovered = headerRect.Contains(evt.mousePosition);

                if (hovered && GUIClip.visibleRect.Contains(evt.mousePosition))
                {
                    if (!GUIStyle.IsTooltipActive(tooltip))
                    {
                        s_ToolTipRect = new Rect(evt.mousePosition, Vector2.zero);
                    }
                    GUIStyle.SetMouseTooltip(tooltip, s_ToolTipRect);
                }
            }
            if (Event.current.type == EventType.MouseUp && sizeRect.Contains(Event.current.mousePosition))
            {
                Event.current.type = EventType.Used;
            }

            EditorGUI.BeginChangeCheck();
            if (!m_OriginalProperty.hasMultipleDifferentValues)
            {
                EditorGUI.BeginProperty(headerRect, GUIContent.none, m_OriginalProperty);
            }

            bool prevEnabled = GUI.enabled;

            GUI.enabled         = true;
            Property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(headerRect, Property.isExpanded, label ?? GUIContent.Temp(Property.displayName));
            EditorGUI.EndFoldoutHeaderGroup();
            GUI.enabled = prevEnabled;

            if (!m_OriginalProperty.hasMultipleDifferentValues)
            {
                EditorGUI.EndProperty();
            }

            if (EditorGUI.EndChangeCheck())
            {
                if (Event.current.alt)
                {
                    EditorGUI.SetExpandedRecurse(Property, Property.isExpanded);
                }

                m_ReorderableList.ClearCacheRecursive();
            }

            DrawChildren(r, headerRect, sizeRect, visibleArea, prevType);
        }
Esempio n. 23
0
    public static void ShowShootParameters(ShootParameters shootParameters, float indentValue, ref bool showProjectileParameters)
    {
        SerializedObject serializedParameters = new SerializedObject(shootParameters);

        serializedParameters.Update();

        #region Base Parameters
        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Base Parameters", EditorStyles.boldLabel);

        SerializedProperty projectilePrefabAttribute = serializedParameters.FindProperty("projectilePrefab");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), projectilePrefabAttribute);

        SerializedProperty cadenceProperty = serializedParameters.FindProperty("shootCadence");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), cadenceProperty, new GUIContent("Shoot Cadence", "The reloading time needed after a shot to be able to shoot again"));
        if (cadenceProperty.floatValue < 0)
        {
            cadenceProperty.floatValue = 0;
        }

        SerializedProperty numberOfProjectilesPerShotProperty = serializedParameters.FindProperty("numberOfProjectilesPerShot");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), numberOfProjectilesPerShotProperty, new GUIContent("Number of Projectiles per Shot", "The number of projectile that will be instantiated on shot by each shoot origins of the weapon. Generaly of one except for shotguns"));
        if (numberOfProjectilesPerShotProperty.intValue < 1)
        {
            numberOfProjectilesPerShotProperty.intValue = 1;
        }

        SerializedProperty imprecisionAngleProperty = serializedParameters.FindProperty("imprecisionAngle");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), imprecisionAngleProperty, new GUIContent("Imprecision Angle", "The angle of the cone in which the projectile direction will be randomly picked on shot. Set low for precise shots, set high for spray"));
        if (imprecisionAngleProperty.floatValue < 0)
        {
            imprecisionAngleProperty.floatValue = 0;
        }
        #endregion

        #region Serial Shots
        GUILayout.Space(20);
        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Serial Shots", EditorStyles.boldLabel);

        SerializedProperty numberOfSerialShotsProperty = serializedParameters.FindProperty("numberOfSerialShots");
        bool isSerialShot = EditorGUI.Toggle(EditorStaticMethods.GetIndentedControlRect(indentValue), new GUIContent("Is Serial Shots", "Set true if you want a burst shot"), numberOfSerialShotsProperty.intValue > 1);

        if (isSerialShot)
        {
            if (numberOfSerialShotsProperty.intValue < 2)
            {
                numberOfSerialShotsProperty.intValue = 3;
            }

            EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), numberOfSerialShotsProperty, new GUIContent("Number of Shots", "The number of shots that will be done through the burst shot"));

            SerializedProperty timeBetweenEachSerialShotProperty = serializedParameters.FindProperty("timeBetweenEachSerialShot");
            EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), timeBetweenEachSerialShotProperty, new GUIContent("Time between each Shot", "The time between two shots of the burst shot"));

            if (numberOfSerialShotsProperty.intValue < 2)
            {
                numberOfSerialShotsProperty.intValue = 2;
            }

            if (timeBetweenEachSerialShotProperty.floatValue < 0)
            {
                timeBetweenEachSerialShotProperty.floatValue = 0;
            }
        }
        else
        {
            if (numberOfSerialShotsProperty.intValue != 1)
            {
                numberOfSerialShotsProperty.intValue = 1;
            }
        }
        #endregion

        #region Projectile Parameters
        GUILayout.Space(20);

        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Projectiles Parameters", EditorStyles.boldLabel);

        SerializedProperty projParamsAttribute = serializedParameters.FindProperty("projectileParameters");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), projParamsAttribute);

        serializedParameters.ApplyModifiedProperties();

        ProjectileParameters projParams = shootParameters.GetProjectileParameters;
        if (projParams != null)
        {
            showProjectileParameters = EditorGUI.BeginFoldoutHeaderGroup(EditorStaticMethods.GetIndentedControlRect(indentValue), showProjectileParameters, (showProjectileParameters ? "Close" : "Open") + " Projectile Parameters", showProjectileParameters ? EditorStyles.boldLabel : null);
            EditorGUI.EndFoldoutHeaderGroup();

            if (showProjectileParameters)
            {
                EditorGUILayout.BeginVertical("box");
                ProjectileParametersInspector.ShowProjectileParameters(projParams, indentValue + 15);
                EditorGUILayout.EndVertical();
            }
        }
        #endregion
    }
Esempio n. 24
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (panel == null && property.serializedObject != null)
            {
                panel = (IPanelUI)property.serializedObject.targetObject;
            }

            Rect rect = new Rect(position.x, position.y,
                                 position.width, EditorGUIUtility.singleLineHeight);

            visible = EditorGUI.BeginFoldoutHeaderGroup(rect, visible, label);
            if (visible)
            {
                EditorGUI.DrawRect(position, eventRectColor);

                var indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;

                rect.y     += EditorGUIUtility.singleLineHeight;
                rect.width *= .5f;
                rect.width -= padding * 2;
                rect.x     += padding;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative("type"), GUIContent.none);
                rect.x += rect.width + padding * 2;
                EditorGUIUtility.labelWidth = 82;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative("timeToFinish"));

                rect.width += padding * 2;
                rect.width *= 2;
                rect.x      = position.x;
                rect.y     += EditorGUIUtility.singleLineHeight;
                switch ((PopupAnimationType)property.FindPropertyRelative("type").enumValueIndex)
                {
                case PopupAnimationType.Off:
                    break;

                case PopupAnimationType.Linear:
                case PopupAnimationType.Quadratic:
                    DrawLerpControls(rect, property);
                    break;

                case PopupAnimationType.CustomRoutine:
                    EditorGUI.PropertyField(rect, property.FindPropertyRelative("animationRoutine"), GUIContent.none);
                    break;

                case PopupAnimationType.CustomCurve:
                    EditorGUI.PropertyField(rect, property.FindPropertyRelative("animationCurve"), GUIContent.none);
                    rect.y += EditorGUIUtility.singleLineHeight;
                    DrawLerpControls(rect, property);
                    break;

                case PopupAnimationType.Anchors:
                    DrawAnchorLerpControls(rect, property);
                    break;
                }

                // Set indent back to what it was
                EditorGUI.indentLevel = indent;
            }
            EditorGUI.EndFoldoutHeaderGroup();
        }
        void DrawElementCallback(Rect rect, int index, bool active, bool focused)
        {
            var element = appParams[index];

            element.hasError = element.appParam == null || string.IsNullOrEmpty(element.name) || element.instanceCount == 0 || NameAtIndexAlreadyUsed(index);

            var rc = rect;

            rc.height = 20;
            rc.x     += 15;
            rc.width -= 15;

#if UNITY_2019_3_OR_NEWER
            element.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(rc, element.isExpanded, element.name);
#endif
            if (element.isExpanded)
            {
                EditorGUI.indentLevel++;

                if (string.IsNullOrEmpty(element.name) || NameAtIndexAlreadyUsed(index))
                {
                    rc.y     += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    rc.height = EditorGUIUtility.singleLineHeight;
                    EditorGUI.HelpBox(rc, "App parameter name must not be empty or used previously.", MessageType.Error);
                }

                rc.y        += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                rc.height    = EditorGUIUtility.singleLineHeight;
                element.name = EditorGUI.TextField(rc, "Name", element.name);

                if (element.instanceCount == 0)
                {
                    rc.y     += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    rc.height = EditorGUIUtility.singleLineHeight;
                    EditorGUI.HelpBox(rc, "App parameter instances must be greater than 0.", MessageType.Error);
                }

                rc.y                 += rc.height + EditorGUIUtility.standardVerticalSpacing;
                rc.height             = EditorGUIUtility.singleLineHeight;
                element.instanceCount = EditorGUI.IntField(rc, "Instances", element.instanceCount);

                var lastAppParam = element.appParam;

                if (element.appParam == null)
                {
                    rc.y     += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    rc.height = EditorGUIUtility.singleLineHeight;
                    EditorGUI.HelpBox(rc, "App parameter must be assigned a ScriptableObject", MessageType.Error);
                }

                rc.y            += rc.height + EditorGUIUtility.standardVerticalSpacing;
                rc.height        = EditorGUIUtility.singleLineHeight;
                element.appParam = EditorGUI.ObjectField(rc, "ScriptableObject", element.appParam, typeof(ScriptableObject), false) as ScriptableObject;

                if (element.appParam != lastAppParam)
                {
                    if (element.appParam != null)
                    {
                        if (element.instanceCount == 0)
                        {
                            element.instanceCount = 1;
                        }

                        element.json          = JsonUtility.ToJson(element.appParam, true).Trim();
                        element.jsonLineCount = element.json.Split('\n').Length;
                    }
                    else
                    {
                        element.name          = "";
                        element.instanceCount = 0;
                    }
                }

                if (element.appParam != null)
                {
                    rc.y += rc.height + EditorGUIUtility.standardVerticalSpacing;
                    element.expandJson = EditorGUI.Foldout(rc, element.expandJson, "JSON");
                    if (element.expandJson)
                    {
                        rc.y     += rc.height + EditorGUIUtility.standardVerticalSpacing;
                        rc.height = element.jsonLineCount * EditorGUIUtility.singleLineHeight;
                        EditorGUI.TextArea(rc, element.json);
                    }
                }

                EditorGUI.indentLevel--;
            }
#if UNITY_2019_3_OR_NEWER
            EditorGUI.EndFoldoutHeaderGroup();
#endif
        }
Esempio n. 26
0
        void DrawInputConfig(InputDataConfig inputConfig)
        {
            int selectedindex;

            BuildDataConfig config = Config;

            if (OutputDataFormats == null)
            {
                OutputDataFormats = new GUIContent[] { new GUIContent("json") }
            }
            ;

            GUILayout.Label("Input".Localization());
            using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
            {
                using (new GUILayout.HorizontalScope())
                {
                    EditorGUILayout.PrefixLabel("Provider".Localization());
                    inputConfig.Provider = EditorGUILayoutx.ProviderTypeName(inputConfig.Provider, EditorBuildData.PackageDir, "^Build\\.Data\\.Provider\\.(.*)\\.dll$|BuildData\\.exe", "Build.Data.DataReader");
                }

                inputConfig.Directory   = new GUIContent("Directory".Localization(), "").FolderField(inputConfig.Directory, "Data Source Folder", relativePath: relativePath);
                inputConfig.FileInclude = EditorGUILayout.TextField(new GUIContent("File Include".Localization(), "Regex, excel(\\.xlsx?$)"), inputConfig.FileInclude ?? string.Empty);
                inputConfig.FileExclude = EditorGUILayout.TextField(new GUIContent("File Exclude".Localization(), "Regex, excel(~\\$)"), inputConfig.FileExclude ?? string.Empty);


                EditorGUILayout.LabelField("Table".Localization());
                using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                {
                    inputConfig.TableName = EditorGUILayout.TextField(new GUIContent("Table Name".Localization()), inputConfig.TableName ?? string.Empty);
                    using (new GUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel("Offset".Localization().Localization());
                        GUILayout.Label(new GUIContent("Row".Localization().Localization()), GUILayout.ExpandWidth(false));
                        inputConfig.OffsetRow = EditorGUILayout.IntField(inputConfig.OffsetRow);
                        GUILayout.Label(new GUIContent("Column".Localization().Localization()), GUILayout.ExpandWidth(false));
                        inputConfig.OffsetColumn = EditorGUILayout.IntField(inputConfig.OffsetColumn);
                    }
                }


                EditorGUILayout.LabelField("Field".Localization());
                using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                {
                    inputConfig.TagInclude = EditorGUILayout.DelayedTextField(new GUIContent("Tag Include".Localization()), inputConfig.TagInclude ?? string.Empty);
                    inputConfig.TagExclude = EditorGUILayout.DelayedTextField(new GUIContent("Tag Exclude".Localization()), inputConfig.TagExclude ?? string.Empty);
                }

                EditorGUILayout.LabelField("Data".Localization());
                using (new EditorGUILayoutx.Scopes.IndentLevelVerticalScope())
                {
                    inputConfig.ArraySeparator  = new GUIContent("Array Separator".Localization()).DelayedPlaceholderField(inputConfig.ArraySeparator ?? string.Empty, new GUIContent(InputDataConfig.DefaultArraySeparator));
                    inputConfig.ObjectSeparator = new GUIContent("Object Separator".Localization()).DelayedPlaceholderField(inputConfig.ObjectSeparator ?? string.Empty, new GUIContent(InputDataConfig.DefaultObjectSeparator));
                }



                if (inputConfig.Rows == null)
                {
                    inputConfig.Rows = new DataRowConfig[0];
                }

                Rect rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none);


                if (GUI.Button(new Rect(rect.xMax - 16, rect.y, 16, rect.height), "+", GUIStyle.none))
                {
                    GenericMenu menu = new GenericMenu();

                    foreach (DataRowType rowType in Enum.GetValues(typeof(DataRowType)))
                    {
                        if (inputConfig.Rows.FirstOrDefault(o => o.Type == rowType) == null)
                        {
                            menu.AddItem(new GUIContent(rowType.ToString()), false, (userData) =>
                            {
                                addRowType  = (DataRowType)userData;
                                rowsFoldout = true;
                            }, rowType);
                        }
                    }

                    menu.ShowAsContext();
                }

                if (addRowType != 0)
                {
                    //Undo.undoRedoPerformed += () =>
                    //{
                    //    Debug.Log("   Undo.undoRedoPerformed " + addRowType);
                    //};
                    //Undo.willFlushUndoRecord += () =>
                    //{
                    //    Debug.Log(" Undo.willFlushUndoRecord " + addRowType);
                    //};
                    var dataRow = new DataRowConfig()
                    {
                        Type = addRowType
                    };
                    var rows = inputConfig.Rows;
                    ArrayUtility.Insert(ref inputConfig.Rows, inputConfig.Rows.Length, dataRow);
                    GUI.changed = true;
                    //Undo.IncrementCurrentGroup();
                    //Undo.SetCurrentGroupName("addRowType");

                    addRowType = 0;
                }

                rowsFoldout = EditorGUI.BeginFoldoutHeaderGroup(new Rect(rect.x, rect.y, rect.width - 20, rect.height), rowsFoldout, new GUIContent("Row Declaration".Localization()));
                //rowsFoldout=EditorGUILayout.BeginToggleGroup( new GUIContent("Rows"),rowsFoldout);


                EditorGUI.indentLevel++;
                if (rowsFoldout)
                {
                    foreach (var row in inputConfig.Rows.OrderBy(o => o.Index).ToArray())
                    {
                        int index = Array.FindIndex(inputConfig.Rows, o => o == row);
                        DrawDataRowConfig(inputConfig, row, index);
                    }
                }
                EditorGUI.indentLevel--;
                EditorGUI.EndFoldoutHeaderGroup();
                //EditorGUILayout.EndToggleGroup();
            }
        }

        bool rowsFoldout;
        DataRowType addRowType;

        int deleteRowIndex = -1;
        void DrawDataRowConfig(InputDataConfig inputConfig, DataRowConfig row, int index)
        {
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(16 * EditorGUI.indentLevel);
                var oldIndentLevel = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;
                using (new GUILayout.VerticalScope("box"))
                {
                    using (new GUILayout.HorizontalScope())
                    {
                        EditorGUILayout.LabelField(row.Type.ToString().Localization());
                        GUIStyle style = new GUIStyle("label");
                        style.fontSize      = (int)(style.fontSize * 1.2f);
                        style.padding.top   = 0;
                        style.padding.right = 0;
                        style.margin.right  = 0;
                        if (GUILayout.Button("◥", style, GUILayout.ExpandWidth(false)))
                        {
                            GenericMenu menu = new GenericMenu();
                            menu.AddItem(new GUIContent("Delete".Localization()), false, () =>
                            {
                                deleteRowIndex = index;
                            });
                            menu.ShowAsContext();
                        }
                        GUILayout.Space(10);
                    }
                    EditorGUI.indentLevel++;
                    row.Index        = EditorGUILayout.DelayedIntField("Index".Localization(), row.Index);
                    row.Pattern      = EditorGUILayout.DelayedTextField("Pattern".Localization(), row.Pattern);
                    row.ValuePattern = EditorGUILayout.DelayedTextField("Value Pattern".Localization(), row.ValuePattern);

                    EditorGUI.indentLevel--;
                }
                EditorGUI.indentLevel = oldIndentLevel;
            }


            if (deleteRowIndex >= 0 && deleteRowIndex < inputConfig.Rows.Length)
            {
                ArrayUtility.RemoveAt(ref inputConfig.Rows, deleteRowIndex);
                deleteRowIndex = -1;
                GUI.changed    = true;
            }
        }

        void DrawCodeConfig(BuildCodeConfig codeConfig)
        {
            EditorGUILayout.LabelField("Generate Code".Localization());
            EditorGUI.indentLevel++;
            codeConfig.Path      = new GUIContent("Path".Localization(), "").FileField(codeConfig.Path ?? string.Empty, "dll", "Build Code File", relativePath: relativePath);
            codeConfig.Namespace = EditorGUILayout.TextField(new GUIContent("Namespace".Localization()), codeConfig.Namespace ?? string.Empty);
            codeConfig.TypeName  = EditorGUILayout.TextField(new GUIContent("TypeName".Localization()), codeConfig.TypeName ?? string.Empty);
            EditorGUI.indentLevel--;
        }
Esempio n. 27
0
 public static IDisposable FoldoutHeaderGroup(Rect position, ref bool foldout, GUIContent content, [DefaultValue("EditorStyles.foldoutHeader")] GUIStyle style = null, Action <Rect> menuAction = null, GUIStyle menuIcon = null
                                              , Action ifVisible = null)
 {
     foldout = EditorGUI.BeginFoldoutHeaderGroup(position, foldout, content, style, menuAction, menuIcon);
     return(FinishFoldoutHeaderGroup(foldout, ifVisible));
 }
Esempio n. 28
0
        private void TransitionTableGUI()
        {
            Separator();
            EditorGUILayout.HelpBox("Click on any State's name to see the Transitions it contains, or click the Pencil/Wrench icon to see its Actions.", MessageType.Info);
            Separator();

            // For each fromState
            for (int i = 0; i < _fromStates.Count; i++)
            {
                var stateRect = BeginVertical(ContentStyle.WithPaddingAndMargins);
                EditorGUI.DrawRect(stateRect, ContentStyle.LightGray);

                var transitions = _transitionsByFromStates[i];

                // State Header
                var headerRect = BeginHorizontal();
                {
                    BeginVertical();
                    string label = transitions[0].SerializedTransition.FromState.objectReferenceValue.name;
                    if (i == 0)
                    {
                        label += " (Initial State)";
                    }

                    headerRect.height = EditorGUIUtility.singleLineHeight;
                    GUILayoutUtility.GetRect(headerRect.width, headerRect.height);
                    headerRect.x += 5;

                    // Toggle
                    {
                        var toggleRect = headerRect;
                        toggleRect.width -= 140;
                        _toggledIndex     =
                            EditorGUI.BeginFoldoutHeaderGroup(toggleRect, _toggledIndex == i, label, ContentStyle.StateListStyle) ?
                            i : _toggledIndex == i ? -1 : _toggledIndex;
                    }

                    Separator();
                    EndVertical();

                    // State Header Buttons
                    {
                        bool Button(Rect position, string icon) => GUI.Button(position, EditorGUIUtility.IconContent(icon));

                        var buttonRect = new Rect(x: headerRect.width - 25, y: headerRect.y, width: 35, height: 20);

                        // Move state down
                        if (i < _fromStates.Count - 1)
                        {
                            if (Button(buttonRect, "scrolldown"))
                            {
                                ReorderState(i, false);
                                EarlyOut();
                                return;
                            }
                            buttonRect.x -= 40;
                        }

                        // Move state up
                        if (i > 0)
                        {
                            if (Button(buttonRect, "scrollup"))
                            {
                                ReorderState(i, true);
                                EarlyOut();
                                return;
                            }
                            buttonRect.x -= 40;
                        }

                        // Switch to state editor
                        if (Button(buttonRect, "SceneViewTools"))
                        {
                            DisplayStateEditor(transitions[0].SerializedTransition.FromState.objectReferenceValue);
                            EarlyOut();
                            return;
                        }

                        void EarlyOut()
                        {
                            EndHorizontal();
                            EndFoldoutHeaderGroup();
                            EndVertical();
                            EndHorizontal();
                        }
                    }
                }
                EndHorizontal();

                if (_toggledIndex == i)
                {
                    EditorGUI.BeginChangeCheck();
                    stateRect.y += EditorGUIUtility.singleLineHeight * 2;

                    foreach (var transition in transitions)                     // Display all the transitions in the state
                    {
                        if (transition.Display(ref stateRect))                  // Return if there were changes
                        {
                            EditorGUI.EndChangeCheck();
                            EndFoldoutHeaderGroup();
                            EndVertical();
                            EndHorizontal();
                            return;
                        }
                        Separator();
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                    }
                }

                EndFoldoutHeaderGroup();
                EndVertical();
                Separator();
            }

            var rect = BeginHorizontal();

            Space(rect.width - 55);

            // Display add transition button
            _addTransitionHelper.Display(rect);

            EndHorizontal();
        }
    private void TransitionTableGUI()
    {
        Separator();
        EditorGUILayout.HelpBox("Click on any State's name to see the Transitions it contains, or click the Pencil/Wrench icon to see its Actions.", MessageType.Info);
        Separator();

        serializedObject.UpdateIfRequiredOrScript();

        // For each fromState
        for (int i = 0; i < _fromStates.Count; i++)
        {
            var stateRect = BeginVertical(ContentStyle.WithPaddingAndMargins);
            EditorGUI.DrawRect(stateRect, ContentStyle.LightGray);

            var transitions = _transitionsByFromStates[i];

            // State Header
            var headerRect = BeginHorizontal();
            {
                BeginVertical();
                string label = transitions[0].SerializedTransition.FromState.objectReferenceValue.name;
                if (i == 0)
                {
                    label += " (Initial State)";
                }

                headerRect.height = EditorGUIUtility.singleLineHeight;
                GUILayoutUtility.GetRect(headerRect.width, headerRect.height);
                headerRect.x += 5;

                // Toggle
                {
                    var toggleRect = headerRect;
                    toggleRect.width -= 140;
                    _toggles[i]       = EditorGUI.BeginFoldoutHeaderGroup(toggleRect,
                                                                          foldout: _toggles[i],
                                                                          content: label,
                                                                          style: ContentStyle.StateListStyle);
                }

                Separator();
                EndVertical();

                // State Header Buttons
                {
                    bool Button(Rect position, string icon) => GUI.Button(position, EditorGUIUtility.IconContent(icon));

                    var buttonRect = new Rect(
                        x: headerRect.width - 105,
                        y: headerRect.y,
                        width: 35,
                        height: 20);

                    // Switch to state editor
                    if (Button(buttonRect, "SceneViewTools"))
                    {
                        if (_cachedStateEditor == null)
                        {
                            _cachedStateEditor = CreateEditor(transitions[0].SerializedTransition.FromState.objectReferenceValue, typeof(StateEditor));
                        }
                        else
                        {
                            CreateCachedEditor(transitions[0].SerializedTransition.FromState.objectReferenceValue, typeof(StateEditor), ref _cachedStateEditor);
                        }

                        _displayStateEditor = true;
                        return;
                    }

                    buttonRect.x += 40;
                    // Move state up
                    if (Button(buttonRect, "scrollup"))
                    {
                        if (ReorderState(i, true))
                        {
                            return;
                        }
                    }

                    buttonRect.x += 40;
                    // Move state down
                    if (Button(buttonRect, "scrolldown"))
                    {
                        if (ReorderState(i, false))
                        {
                            return;
                        }
                    }
                }
            }
            EndHorizontal();

            // If state is open
            if (_toggles[i])
            {
                DisableAllStateTogglesExcept(i);
                EditorGUI.BeginChangeCheck();

                stateRect.y += EditorGUIUtility.singleLineHeight * 2;
                // Display all the transitions in the state
                foreach (var transition in transitions)
                {
                    if (transition.Display(ref stateRect))
                    {
                        return;
                    }
                    Separator();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }

            EndFoldoutHeaderGroup();
            EndVertical();
            //GUILayout.HorizontalSlider(0, 0, 0);
            Separator();
        }

        var rect = BeginHorizontal();

        Space(rect.width - 55);

        // Display add transition button
        _addTransitionHelper.Display(rect);

        EndHorizontal();
    }
Esempio n. 30
0
        private void OnEnable()
        {
            // Get target
            m_target = (AzureEventController)target;

            // Find the serialized properties
            m_scanMode  = serializedObject.FindProperty("scanMode");
            m_eventList = serializedObject.FindProperty("eventList");

            // Create event system list
            m_reorderableEventList = new ReorderableList(serializedObject, m_eventList, true, true, true, true)
            {
                drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                    rect.y += 2;
                    var element = m_reorderableEventList.serializedProperty.GetArrayElementAtIndex(index);
                    var height  = EditorGUIUtility.singleLineHeight;

                    element.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(new Rect(rect.x, rect.y, rect.width, height), element.isExpanded, "Event Action " + index.ToString());
                    if (element.isExpanded)
                    {
                        // Date settings
                        rect.y += height + 6;
                        int[] dateSelector = new int[3];
                        dateSelector[0] = element.FindPropertyRelative("day").intValue;
                        dateSelector[1] = element.FindPropertyRelative("month").intValue;
                        dateSelector[2] = element.FindPropertyRelative("year").intValue;
                        GUI.color       = m_alphaColor;
                        EditorGUI.LabelField(new Rect(rect.x - 3, rect.y - 3, rect.width + 8, height + 5), "", m_headerStyle);
                        GUI.color = Color.white;
                        EditorGUI.MultiIntField(new Rect(rect.x, rect.y, rect.width, height), m_dateSelectorContent, dateSelector);
                        element.FindPropertyRelative("day").intValue   = dateSelector[0];
                        element.FindPropertyRelative("month").intValue = dateSelector[1];
                        element.FindPropertyRelative("year").intValue  = dateSelector[2];

                        // Time settings
                        rect.y += height + 4;
                        int[] timeSelector = new int[2];
                        timeSelector[0] = element.FindPropertyRelative("hour").intValue;
                        timeSelector[1] = element.FindPropertyRelative("minute").intValue;
                        GUI.color       = m_alphaColor;
                        EditorGUI.LabelField(new Rect(rect.x - 3, rect.y - 3, rect.width + 8, height + 5), "", m_headerStyle);
                        GUI.color = Color.white;
                        EditorGUI.MultiIntField(new Rect(rect.x, rect.y, rect.width, height), m_timeSelectorContent, timeSelector);
                        element.FindPropertyRelative("hour").intValue   = timeSelector[0];
                        element.FindPropertyRelative("minute").intValue = timeSelector[1];

                        // UnityEvent list
                        rect.y += height + 4;
                        EditorGUI.PropertyField(new Rect(rect.x - 2, rect.y, rect.width + 6, height), element.FindPropertyRelative("eventAction"), m_guiContent[2]);
                    }
                    EditorGUI.EndFoldoutHeaderGroup();
                },

                onAddCallback = (ReorderableList l) =>
                {
                    var index = l.serializedProperty.arraySize;
                    l.serializedProperty.arraySize++;
                    l.index = index;
                },

                drawHeaderCallback = (Rect rect) =>
                {
                    EditorGUI.LabelField(rect, m_guiContent[1], EditorStyles.boldLabel);
                },

                elementHeightCallback = (int index) =>
                {
                    var element       = m_reorderableEventList.serializedProperty.GetArrayElementAtIndex(index);
                    var elementHeight = EditorGUI.GetPropertyHeight(element);
                    var margin        = EditorGUIUtility.standardVerticalSpacing;
                    if (element.isExpanded)
                    {
                        return(elementHeight - 50);
                    }
                    else
                    {
                        return(elementHeight + margin);
                    }
                },

                drawElementBackgroundCallback = (rect, index, active, focused) =>
                {
                    if (active)
                    {
                        GUI.Box(new Rect(rect.x + 2, rect.y, rect.width - 4, rect.height + 2), "", "selectionRect");
                    }
                }
            };
        }