Exemplo n.º 1
0
    private void OnGUI()
    {
        serializedObject.Update();
        HandleInput();

        //Main box for everything - START
        GUILayout.BeginVertical(GUI.skin.box);

        //A set of bools for selecting which axis I wish to rotate the selection of GameObjects around
        EditorGUILayout.LabelField("Select axises to rotate around");
        GUILayout.BeginHorizontal(GUI.skin.box);
        EditorGUIUtility.labelWidth = CalculateLabelWidth(xRotProp.displayName, 5f);

        //Using SerializedProperty for drawing the checkboxes.
        EditorGUILayout.PropertyField(xRotProp);
        EditorGUILayout.PropertyField(yRotProp);
        EditorGUILayout.PropertyField(zRotProp);

        //Resetting the labelWidth
        ResetLabelWidth();
        GUILayout.EndHorizontal();

        EditorGUILayout.Space();

        //Using a slider to select the max angle I want to have stuff rotated to
        EditorGUILayout.LabelField("Select rotation offset limit");
        GUILayout.BeginVertical(GUI.skin.box);
        EditorGUIUtility.labelWidth = CalculateLabelWidth(rotationOffsetProp.displayName, 5f);
        EditorGUILayout.Slider(property: rotationOffsetProp, leftValue: 0f, rightValue: 180f);
        ResetLabelWidth();
        GUILayout.EndVertical();

        EditorGUILayout.Space();

        //If the rotate button is pressed without having the proper parameters provided, a dialogue box appears
        if (GUILayout.Button($"Apply random rotation to {Selection.gameObjects.Length} objects"))
        {
            if (!xRot && !yRot && !zRot || Selection.gameObjects.Length == 0)
            {
                EditorUtility.DisplayDialog("FATAL ERROR", "Pls check at least one box and select at least 1 object.", " :)))) ");
                return;
            }
            Rotate(Selection.gameObjects, rotationOffset, xRot, yRot, zRot);
        }

        //Resets transforms
        if (GUILayout.Button("Reset selected Transforms"))
        {
            if (Selection.gameObjects.Length != 0)
            {
                ResetRotation(Selection.gameObjects);
            }
        }

        //Main box for everything - END
        GUILayout.EndVertical();

        //Doing a null-check to avoid an error being thrown when using ESC-key to close the window.
        serializedObject?.ApplyModifiedProperties();
    }
        private void Apply(int index)
        {
            serializedObject.ApplyModifiedProperties();
            _styleAssetSerializedObject?.ApplyModifiedProperties();

            ((Style)target).Apply(index);
        }
Exemplo n.º 3
0
 public void DoLayoutDraw()
 {
     if (List != null && List.count > 0)
     {
         owner?.UpdateIfRequiredOrScript();
         EditorGUI.BeginChangeCheck();
         var re = property.FindPropertyRelative("relational");
         EditorGUILayout.PropertyField(re, new GUIContent("(?)条件关系表达式", re.tooltip));
         if (EditorGUI.EndChangeCheck())
         {
             owner?.ApplyModifiedProperties();
         }
     }
     owner?.UpdateIfRequiredOrScript();
     List?.DoLayoutList();
     owner?.ApplyModifiedProperties();
 }
Exemplo n.º 4
0
        /// <summary>
        /// The serialized property for color temperature is stored in the build-in light editor, and we need to use this object to apply the update.
        /// </summary>
        /// <param name="value">The value to update</param>
        /// <param name="preset">The preset range</param>
        protected virtual void SetValueToPreset(SerializedProperty value, LightUnitSliderUIRange preset)
        {
            m_SerializedObject?.Update();

            // Set the value to the average of the preset range.
            value.floatValue = preset.presetValue;

            m_SerializedObject?.ApplyModifiedProperties();
        }
Exemplo n.º 5
0
        /// <summary> Draws standard field editors for all public fields </summary>
        public virtual void OnBodyGUI()
        {
            PortPositions = PortPositions ?? new Dictionary<INodePort, Vector2>();
            PortPositions.Clear();

            SerializedObject?.Update();

            Draw(_bodyDrawers);

            SerializedObject?.ApplyModifiedProperties();
        }
Exemplo n.º 6
0
 void OnDisable()
 {
     EditorApplication.update -= UpdateGraphEditorWindow;
     _config?.CleanupEditor(_object);
     _object?.ApplyModifiedProperties();
     _config           = null;
     _object           = null;
     _graph            = null;
     titleContent.text = "Graph Editor";
     Repaint();
 }
Exemplo n.º 7
0
        /// <summary>
        /// Displays popups for the selected NavTiles and NavLinks.
        /// </summary>
        private void DrawAreaIndexPopUp()
        {
            _serializedNavTileSelection?.Update();
            _serializedNavLinkSelection?.Update();

            if (_serializedNavTileAreaIndex != null)
            {
                EditorGUILayout.LabelField("Selected NavTiles", EditorStyles.boldLabel);
                EditorHelper.DrawCompressedPopup(_serializedNavTileAreaIndex, NavTileManager.Instance.AreaManager.AllAreaNames);

                EditorGUILayout.Space();
            }

            if (_serializedNavLinkAreaIndex != null)
            {
                EditorGUILayout.LabelField("Selected NavLinks", EditorStyles.boldLabel);
                EditorHelper.DrawCompressedPopup(_serializedNavLinkAreaIndex, NavTileManager.Instance.AreaManager.AllAreaNames);

                EditorGUILayout.Space();
            }

            _serializedNavTileSelection?.ApplyModifiedProperties();
            _serializedNavLinkSelection?.ApplyModifiedProperties();
        }
Exemplo n.º 8
0
        public override void OnInspectorGUI()
        {
            if (tileManager == null)
            {
                tileManager = FindObjectOfType <TileManager>();
            }

            base.DrawDefaultInspector();

            AdjacencyStateMaintainer connector    = (AdjacencyStateMaintainer)target;
            TileObject         tileObject         = connector.GetComponentInParent <TileObject>();
            AdjacencyConnector adjacencyConnector = (AdjacencyConnector)connector;


            // Load the neighbours
            neighbourTiles = tileManager.GetAdjacentTileObjects(tileObject);

            blocked = ParseBitmap(connector.TileState.blockedDirection);

            serializedObject.Update();
            EditorGUILayout.PrefixLabel("Blocked direction");

            // Top line
            EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(20));
            EditorGUILayout.Space(15);
            blocked[0] = EditorGUILayout.Toggle(blocked[0]);
            EditorGUILayout.EndHorizontal();


            // Middle line
            EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(20));
            blocked[6] = EditorGUILayout.Toggle(blocked[6]);
            EditorGUILayout.Space(15);
            blocked[2] = EditorGUILayout.Toggle(blocked[2]);
            EditorGUILayout.EndHorizontal();

            // Last line
            EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(20));
            EditorGUILayout.Space(15);
            blocked[4] = EditorGUILayout.Toggle(blocked[4]);
            EditorGUILayout.EndHorizontal();

            if (GUI.changed)
            {
                if (tileObject != null)
                {
                    bool modified        = false;
                    var  connectorSerial = new SerializedObject(connector);
                    connectorSerial.Update();

                    SerializedProperty property = connectorSerial.FindProperty("tileState");
                    property.FindPropertyRelative("blockedDirection").intValue = SetBitmap(blocked);

                    modified = connectorSerial.ApplyModifiedProperties();
                    if (modified)
                    {
                        // Update our neighbour tiles
                        for (int i = 0; i < neighbourTiles.Length; i++)
                        {
                            // Get fixtures on the same layer
                            var stateMaintainer = neighbourTiles[i]?.GetLayer(adjacencyConnector.LayerIndex + 2)?.GetComponent <AdjacencyStateMaintainer>();
                            if (stateMaintainer == null)
                            {
                                continue;
                            }

                            var serialNeighbour = new SerializedObject(stateMaintainer);

                            var propertyNeighbour = serialNeighbour.FindProperty("tileState");
                            var directionPropery  = propertyNeighbour.FindPropertyRelative("blockedDirection");

                            // Set the opposite side blocked
                            byte neighbourBlocked = (byte)directionPropery.intValue;
                            neighbourBlocked = AdjacencyBitmap.SetDirection(neighbourBlocked, DirectionHelper.GetOpposite((Direction)i), blocked[i]);

                            // Finally update the blocked byte;
                            directionPropery.intValue = neighbourBlocked;
                            serialNeighbour.ApplyModifiedProperties();

                            // Refresh the subdata and meshes
                            neighbourTiles[i].RefreshSubData();
                            neighbourTiles[i].RefreshAdjacencies();
                        }

                        tileObject.RefreshSubData();
                        tileObject.RefreshAdjacencies();
                    }
                }
                else
                {
                    Debug.LogWarning("No tileobject found by adjacency editor");
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnApply()
        {
            var curve    = Editor.Curve;
            var settings = Settings;

            // ==============================================    Closed
            if (curve.Closed != closedProperty.boolValue)
            {
                Curve.FireBeforeChange(BGCurve.EventClosed);
                serializedObject.ApplyModifiedProperties();
                Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points, BGCurve.EventClosed));
            }

            if ((int)curve.ForceChangedEventMode != forceChangedEventModeProperty.enumValueIndex)
            {
                Curve.FireBeforeChange(BGCurve.EventForceUpdate);
                serializedObject.ApplyModifiedProperties();
                Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Curve, BGCurve.EventForceUpdate));
            }

            // ==============================================    Points store mode
            if ((int)Curve.PointsMode != pointsModeProperty.enumValueIndex)
            {
                var newPointsMode = (BGCurve.PointsModeEnum)pointsModeProperty.enumValueIndex;

                //ask for confirmation in case changes may affect something else
                if ((Curve.PointsMode == BGCurve.PointsModeEnum.Components) && !BGEditorUtility.Confirm("Convert Points",
                                                                                                        "Are you sure you want to convert points? All existing references to these points will be lost.", "Convert"))
                {
                    return;
                }

                if ((Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsNoTransform && newPointsMode != BGCurve.PointsModeEnum.GameObjectsTransform ||
                     Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsTransform && newPointsMode != BGCurve.PointsModeEnum.GameObjectsNoTransform) &&
                    !BGEditorUtility.Confirm("Convert Points", "Are you sure you want to convert points? All existing GameObjects for points will be deleted.", "Convert"))
                {
                    return;
                }

                editorSelection.Clear();

                //invoke convert
                BGPrivateField.Invoke(Curve, BGCurve.MethodConvertPoints, newPointsMode,
                                      BGCurveEditor.GetPointProvider(newPointsMode, Curve),
                                      BGCurveEditor.GetPointDestroyer(Curve.PointsMode, Curve));

                //this call is not required
                //                serializedObject.ApplyModifiedProperties();
            }

            // ==============================================    2D mode
            if ((int)curve.Mode2D != mode2DProperty.enumValueIndex)
            {
                Curve.FireBeforeChange(BGCurve.Event2D);
                serializedObject.ApplyModifiedProperties();

                var oldEventMode = Curve.EventMode;
                Curve.EventMode = BGCurve.EventModeEnum.NoEvents;

                //force points recalc
                Curve.Apply2D(Curve.Mode2D);

                if (BGEditorUtility.Confirm("Editor handles change", "Do you want to adjust configurable Editor handles (in Scene View) to chosen mode? This affects only current curve.", "Yes"))
                {
                    if (Curve.Mode2D != BGCurve.Mode2DEnum.Off)
                    {
                        Apply2D(settings.HandlesSettings);
                        Apply2D(settings.ControlHandlesSettings);
                    }
                    else
                    {
                        Apply3D(settings.HandlesSettings);
                        Apply3D(settings.ControlHandlesSettings);
                    }
                }

                Curve.EventMode = oldEventMode;

                Curve.FireChange(BGCurveChangedArgs.GetInstance(Curve, BGCurveChangedArgs.ChangeTypeEnum.Points, BGCurve.Event2D));
            }

            // ==============================================    Snapping
            if ((int)curve.SnapType != snapTypeProperty.enumValueIndex)
            {
                SnappingChanged(BGCurve.EventSnapType);
            }

            if ((int)curve.SnapAxis != snapAxisProperty.enumValueIndex)
            {
                SnappingChanged(BGCurve.EventSnapAxis);
            }

            if (Math.Abs((int)curve.SnapDistance - snapDistanceProperty.floatValue) > BGCurve.Epsilon)
            {
                SnappingChanged(BGCurve.EventSnapDistance);
            }

            if ((int)curve.SnapTriggerInteraction != snapTriggerInteractionProperty.enumValueIndex)
            {
                SnappingChanged(BGCurve.EventSnapTrigger);
            }

            if (curve.SnapToBackFaces != snapToBackFacesProperty.boolValue)
            {
                SnappingChanged(BGCurve.EventSnapBackfaces);
            }

            if (curve.SnapMonitoring != snapMonitoringProperty.boolValue)
            {
                SnappingChanged(BGCurve.EventSnapMonitoring);
            }

            // ==============================================    Event mode
            if ((int)curve.EventMode != eventModeProperty.enumValueIndex)
            {
                serializedObject.ApplyModifiedProperties();
            }

            // ==============================================    Control Type
            if ((int)settings.ControlType != controlTypeProperty.enumValueIndex)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// EditorGUILayout Serialize all visible properties in this Scriptable Object. Returns true if expanded;
        /// </summary>
        public virtual bool DrawGui(object target, bool asFoldout, bool includeScriptField)
        {
            if (!expandeds.ContainsKey(target))
            {
                expandeds.Add(target, true);
            }

            Rect rt = EditorGUILayout.GetControlRect();

            EditorGUI.LabelField(rt, SettingsName, (GUIStyle)"BoldLabel");

            // Width a one pixel wider than the header, fixing this.
            rt.width -= 1;

            //Adjust the find button to left align correctly
            rt.xMin += (asFoldout) ? 2 : -7;

            if (GUI.Button(rt, SettingsName, (GUIStyle)"PreButton"))
            {
                EditorGUIUtility.PingObject(Single);
                Application.OpenURL(HelpURL);
            }

            //if (GUI.Button(rt, EditorGUIUtility.IconContent("_Help")))
            //	Application.OpenURL(helpURL);

            //Adjust the xmin back
            rt.xMin += (asFoldout) ? -2 : 7;

            if (asFoldout)
            {
                expandeds[target] = EditorGUI.Foldout(rt, expandeds[target], "");
            }

            // Adjust the find button to left align correctly
            rt.xMin += (asFoldout) ? 2 : -7;

            if (GUI.Button(rt, SettingsName, (GUIStyle)"PreButton"))
            {
                EditorGUIUtility.PingObject(Single);
                Application.OpenURL(HelpURL);
            }


            //rt.xMin += (rt.width - 16);
            //if (GUI.Button(rt, EditorGUIUtility.IconContent("_Help")))
            //	Application.OpenURL(helpURL);

            if (!asFoldout || expandeds[target])
            {
                EditorGUILayout.Space();

                SerializedObject   so = new SerializedObject(Single);
                SerializedProperty sp = so.GetIterator();
                sp.Next(true);

                // Skip drawing the script reference?
                if (!includeScriptField)
                {
                    sp.NextVisible(false);
                }

                EditorGUI.BeginChangeCheck();
                while (sp.NextVisible(false))
                {
                    EditorGUILayout.PropertyField(sp);
                }

                so.ApplyModifiedProperties();

                EditorGUILayout.Space();

                if (EditorGUI.EndChangeCheck())
                {
                    Initialize();
                    AssetDatabase.SaveAssets();
                }
            }
            return(expandeds[target]);
        }
Exemplo n.º 11
0
        public override void OnInspectorGUI()
        {
            serObj.Update();

            GUILayout.Label("Mapping HDR to LDR ranges since 1982", EditorStyles.miniLabel);

            Camera cam = (target as Tonemapping).GetComponent <Camera>();

            if (cam != null)
            {
                if (!cam.allowHDR)
                {
                    EditorGUILayout.HelpBox("The camera is not HDR enabled. This will likely break the Tonemapper.",
                                            MessageType.Warning);
                }
                else if (!(target as Tonemapping).validRenderTextureFormat)
                {
                    EditorGUILayout.HelpBox(
                        "The input to Tonemapper is not in HDR. Make sure that all effects prior to this are executed in HDR.",
                        MessageType.Warning);
                }
            }

            EditorGUILayout.PropertyField(type, new GUIContent("Technique"));

            if (type.enumValueIndex == (decimal)Tonemapping.TonemapperType.UserCurve)
            {
                EditorGUILayout.PropertyField(remapCurve,
                                              new GUIContent("Remap curve", "Specify the mapping of luminances yourself"));
            }
            else if (type.enumValueIndex == (decimal)Tonemapping.TonemapperType.SimpleReinhard)
            {
                EditorGUILayout.PropertyField(exposureAdjustment, new GUIContent("Exposure", "Exposure adjustment"));
            }
            else if (type.enumValueIndex == (decimal)Tonemapping.TonemapperType.Hable)
            {
                EditorGUILayout.PropertyField(exposureAdjustment, new GUIContent("Exposure", "Exposure adjustment"));
            }
            else if (type.enumValueIndex == (decimal)Tonemapping.TonemapperType.Photographic)
            {
                EditorGUILayout.PropertyField(exposureAdjustment, new GUIContent("Exposure", "Exposure adjustment"));
            }
            else if (type.enumValueIndex == (decimal)Tonemapping.TonemapperType.OptimizedHejiDawson)
            {
                EditorGUILayout.PropertyField(exposureAdjustment, new GUIContent("Exposure", "Exposure adjustment"));
            }
            else if (type.enumValueIndex == (decimal)Tonemapping.TonemapperType.AdaptiveReinhard)
            {
                EditorGUILayout.PropertyField(middleGrey,
                                              new GUIContent("Middle grey",
                                                             "Middle grey defines the average luminance thus brightening or darkening the entire image."));
                EditorGUILayout.PropertyField(white,
                                              new GUIContent("White",
                                                             "Smallest luminance value that will be mapped to white"));
                EditorGUILayout.PropertyField(adaptionSpeed,
                                              new GUIContent("Adaption Speed",
                                                             "Speed modifier for the automatic adaption"));
                EditorGUILayout.PropertyField(adaptiveTextureSize,
                                              new GUIContent("Texture size", "Defines the amount of downsamples needed."));
            }
            else if (type.enumValueIndex == (decimal)Tonemapping.TonemapperType.AdaptiveReinhardAutoWhite)
            {
                EditorGUILayout.PropertyField(middleGrey,
                                              new GUIContent("Middle grey",
                                                             "Middle grey defines the average luminance thus brightening or darkening the entire image."));
                EditorGUILayout.PropertyField(adaptionSpeed,
                                              new GUIContent("Adaption Speed",
                                                             "Speed modifier for the automatic adaption"));
                EditorGUILayout.PropertyField(adaptiveTextureSize,
                                              new GUIContent("Texture size", "Defines the amount of downsamples needed."));
            }

            GUILayout.Label("All following effects will use LDR color buffers", EditorStyles.miniBoldLabel);

            serObj.ApplyModifiedProperties();
        }
Exemplo n.º 12
0
    public void DrawDetectZone(Object _source, SerializedObject _sourceRef, Transform _sourceTrans = null)
    {
        Handles.color = debugColor;
        EditorGUI.BeginChangeCheck();

        var pos = offset;

        if (positionType == PositionType.World)
        {
            if (handlePoint != worldPos)
            {
                handlePoint = worldPos;
            }
            handlePoint = Handles.PositionHandle(handlePoint, Quaternion.identity);

            //position points after dragging
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(_source, "Modified " + _source + " properties.");
                worldPos = handlePoint;
                _sourceRef.ApplyModifiedProperties();
                _sourceRef.Update();
            }

            //get final position
            pos = worldPos + offset;
        }
        else if (positionType == PositionType.Local && trans)
        {
            pos = trans.TransformPoint(offset);
        }
        else if (positionType == PositionType.Offset && _sourceTrans)
        {
            pos = _sourceTrans.TransformPoint(offset);
        }

        if (useTransformZAngle)
        {
            if (positionType == PositionType.Local && trans)
            {
                angle = trans.eulerAngles.z;
            }
            else if (positionType == PositionType.Offset && _sourceTrans)
            {
                angle = _sourceTrans.eulerAngles.z;
            }
        }
        Matrix4x4 angleMatrix = Matrix4x4.TRS(pos, Quaternion.Euler(0, 0, angle), Handles.matrix.lossyScale);

        using (new Handles.DrawingScope(angleMatrix))
        {
            //draw the objects
            if (detectType == DetectAreaType.Box)
            {
                Handles.DrawWireCube(Vector2.zero, size);
            }
            else if (detectType == DetectAreaType.Circle)
            {
                Handles.DrawWireDisc(Vector2.zero, Vector3.back, radius);
            }
        }
    }
Exemplo n.º 13
0
        private void OnGUI()
        {
            view?.Update();

            if (!cached)
            {
                if (!isInstance && !isDefinition)
                {
                    isInstance = true;
                }
                cached = true;
            }

            if (!locked && (!focused && FuzzyWindow.instance == null || !focused && focusedWindow != FuzzyWindow.instance))
            {
                Close();
            }

            HUMEditor.Draw(new Rect(new Vector2(0, 0), position.size)).Box(HUMEditorColor.DefaultEditorBackground, Color.black, BorderDrawPlacement.Inside, 1);

            HUMEditor.Horizontal(() =>
            {
                var instance = isInstance;
                isInstance   = EditorGUILayout.Toggle(isInstance, new GUIStyle(GUI.skin.button), GUILayout.Height(24));
                var lastRect = GUILayoutUtility.GetLastRect();
                GUI.Label(lastRect, new GUIContent("Instance"), new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleCenter
                });
                if (isInstance != instance)
                {
                    isDefinition = false;
                }

                var definition = isDefinition;
                isDefinition   = EditorGUILayout.Toggle(isDefinition, new GUIStyle(GUI.skin.button), GUILayout.Height(24));
                lastRect       = GUILayoutUtility.GetLastRect();
                GUI.Label(lastRect, new GUIContent("Definition"), new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleCenter
                });
                if (isDefinition != definition)
                {
                    isInstance = false;
                }

                locked   = EditorGUILayout.Toggle(locked, new GUIStyle(GUI.skin.button), GUILayout.Width(48), GUILayout.Height(24));
                lastRect = GUILayoutUtility.GetLastRect();
                GUI.Label(lastRect, new GUIContent("Locked"), new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleCenter
                });
            });

            scrollPosition = HUMEditor.Draw().ScrollView(scrollPosition, () =>
            {
                if (isInstance)
                {
                    LudiqGUI.InspectorLayout(windowVariablesMetadata);
                }
                if (isDefinition)
                {
                    LudiqGUI.InspectorLayout(variablesMetadata);
                }
            });

            view?.ApplyModifiedProperties();

            if (locked)
            {
                Repaint();
            }
        }
        private void DisplayLoaderSelectionUI()
        {
            BuildTargetGroup buildTargetGroup = EditorGUILayout.BeginBuildTargetSelectionGrouping();

            try
            {
                bool buildTargetChanged = m_LastBuildTargetGroup != buildTargetGroup;
                if (buildTargetChanged)
                {
                    m_LastBuildTargetGroup = buildTargetGroup;
                }

                XRGeneralSettings settings = currentSettings.SettingsForBuildTarget(buildTargetGroup);
                if (settings == null)
                {
                    settings = ScriptableObject.CreateInstance <XRGeneralSettings>() as XRGeneralSettings;
                    currentSettings.SetSettingsForBuildTarget(buildTargetGroup, settings);
                    settings.name = $"{buildTargetGroup.ToString()} Settings";
                    AssetDatabase.AddObjectToAsset(settings, AssetDatabase.GetAssetOrScenePath(currentSettings));
                }

                var serializedSettingsObject = new SerializedObject(settings);
                serializedSettingsObject.Update();

                SerializedProperty initOnStart = serializedSettingsObject.FindProperty("m_InitManagerOnStart");
                EditorGUILayout.PropertyField(initOnStart, Content.k_InitializeOnStart);
                EditorGUILayout.Space();

                SerializedProperty loaderProp = serializedSettingsObject.FindProperty("m_LoaderManagerInstance");

                if (!CachedSettingsEditor.ContainsKey(buildTargetGroup))
                {
                    CachedSettingsEditor.Add(buildTargetGroup, null);
                }

                if (loaderProp.objectReferenceValue == null)
                {
                    var xrManagerSettings = ScriptableObject.CreateInstance <XRManagerSettings>() as XRManagerSettings;
                    xrManagerSettings.name = $"{buildTargetGroup.ToString()} Providers";
                    AssetDatabase.AddObjectToAsset(xrManagerSettings, AssetDatabase.GetAssetOrScenePath(currentSettings));
                    loaderProp.objectReferenceValue = xrManagerSettings;
                    serializedSettingsObject.ApplyModifiedProperties();
                }

                var obj = loaderProp.objectReferenceValue;

                if (obj != null)
                {
                    loaderProp.objectReferenceValue = obj;

                    if (CachedSettingsEditor[buildTargetGroup] == null)
                    {
                        CachedSettingsEditor[buildTargetGroup] = Editor.CreateEditor(obj) as XRManagerSettingsEditor;

                        if (CachedSettingsEditor[buildTargetGroup] == null)
                        {
                            Debug.LogError("Failed to create a view for XR Manager Settings Instance");
                        }
                    }

                    if (CachedSettingsEditor[buildTargetGroup] != null)
                    {
                        if (ResetUi)
                        {
                            ResetUi = false;
                            CachedSettingsEditor[buildTargetGroup].Reload();
                        }

                        CachedSettingsEditor[buildTargetGroup].BuildTarget = buildTargetGroup;
                        CachedSettingsEditor[buildTargetGroup].OnInspectorGUI();
                    }
                }
                else if (obj == null)
                {
                    settings.AssignedSettings       = null;
                    loaderProp.objectReferenceValue = null;
                }

                serializedSettingsObject.ApplyModifiedProperties();
            }
            catch (Exception ex)
            {
                Debug.LogError($"Error trying to display plug-in assingment UI : {ex.Message}");
            }

            EditorGUILayout.EndBuildTargetSelectionGrouping();
        }
Exemplo n.º 15
0
    /// <summary>
    /// Called when the inspector needs to draw
    /// </summary>
    public override void OnInspectorGUI()
    {
        // Pulls variables from runtime so we have the latest values.
        mTargetSO.Update();

        GUILayout.Space(5);

        EditorHelper.DrawInspectorTitle("ootii Scroller Rig");

        EditorHelper.DrawInspectorDescription("Basic camera rig for a 2.5D game that follows the 'anchor', but typically is looking down the Z axis. It does not tilt with the actor.", MessageType.None);

        GUILayout.Space(5);

        bool lNewIsInternalUpdateEnabled = EditorGUILayout.Toggle(new GUIContent("Force Update", "Determines if we allow the camera rig to update itself or if something like the Actor Controller will tell the camera when to update."), mTarget.IsInternalUpdateEnabled);

        if (lNewIsInternalUpdateEnabled != mTarget.IsInternalUpdateEnabled)
        {
            mIsDirty = true;
            mTarget.IsInternalUpdateEnabled = lNewIsInternalUpdateEnabled;
        }

        GUILayout.Space(5);

        Transform lNewAnchor = EditorGUILayout.ObjectField(new GUIContent("Anchor", "Transform the camera is meant to follow."), mTarget.Anchor, typeof(Transform), true) as Transform;

        if (lNewAnchor != mTarget.Anchor)
        {
            mIsDirty       = true;
            mTarget.Anchor = lNewAnchor;
        }

        Vector3 lNewAnchorOffset = EditorGUILayout.Vector3Field(new GUIContent("Anchor Offset", "Position of the camera relative to the anchor."), mTarget.AnchorOffset);

        if (lNewAnchorOffset != mTarget.AnchorOffset)
        {
            mIsDirty             = true;
            mTarget.AnchorOffset = lNewAnchorOffset;
        }

        Vector3 lNewLookDirection = EditorGUILayout.Vector3Field(new GUIContent("Look Direction", "Direction that the camera looks down."), mTarget.LookDirection);

        if (lNewLookDirection != mTarget.LookDirection)
        {
            mIsDirty = true;
            mTarget.LookDirection = lNewLookDirection;
        }

        // If there is a change... update.
        if (mIsDirty)
        {
            // Flag the object as needing to be saved
            EditorUtility.SetDirty(mTarget);

#if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            EditorApplication.MarkSceneDirty();
#else
            if (!EditorApplication.isPlaying)
            {
                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
            }
#endif

            // Pushes the values back to the runtime so it has the changes
            mTargetSO.ApplyModifiedProperties();

            // Clear out the dirty flag
            mIsDirty = false;
        }
    }
 public void ApplyModifiedProperties()
 {
     compositionProfileSO?.ApplyModifiedProperties();
     compositorSO.ApplyModifiedProperties();
 }
Exemplo n.º 17
0
    /// <summary>
    /// Called when the inspector needs to draw
    /// </summary>
    public override void OnInspectorGUI()
    {
        // Pulls variables from runtime so we have the latest values.
        mTargetSO.Update();

        // If the transform has changed, we need to reset the scale
        if (mTarget.transform.hasChanged)
        {
            mTarget.Point.OriginalScale  = mTarget.transform.lossyScale;
            mTarget.transform.hasChanged = false;
        }

        // Clean up the mount points to ensure everything stays in sync
        PreProcessPoints();

        GUILayout.Space(5);

        EditorHelper.DrawInspectorTitle("ootii Mount");

        EditorHelper.DrawInspectorDescription("Manages a single mount point for simple items. This mount cannot be a parent to other mount points.", MessageType.None);

        GUILayout.Space(5);

        if (!IsAddMountPointEnabled(mTarget))
        {
            GUILayout.Space(5);

            EditorGUILayout.HelpBox("Unity prevents mount points from being parented directly on the prefab. Instead, add them to a prefab instance and then press 'apply' to update the prefab.", MessageType.Warning);
        }

        // Show the points
        EditorGUILayout.BeginVertical(EditorHelper.Box);

        bool lItemIsDirty = DrawPointDetailItem(mTarget.Point);

        if (lItemIsDirty)
        {
            mIsDirty = true;
        }

        EditorGUILayout.EndVertical();

        GUILayout.Space(5);

        // If there is a change... update.
        if (mIsDirty)
        {
            // Flag the object as needing to be saved
            EditorUtility.SetDirty(mTarget);

#if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            EditorApplication.MarkSceneDirty();
#else
            if (!EditorApplication.isPlaying)
            {
                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
            }
#endif

            // Pushes the values back to the runtime so it has the changes
            mTargetSO.ApplyModifiedProperties();

            // Clear out the dirty flag
            mIsDirty = false;
        }
    }
        private void DrawValue(Rect rect, MemberInfos infos, string name, string assemblyQualifiedName, ObjectType objectType, string typeName, SerializedProperty valueProperty, SerializedObject serializedObject)
        {
            var fieldProp = valueProperty.GetPropertyOfType(objectType);

            if (fieldProp == null)
            {
                return;
            }

            var typeProperty         = valueProperty.FindPropertyRelative(ValueFields.Type);
            var fullTypeNameProperty = valueProperty.FindPropertyRelative(ValueFields.FullTypeName);

            typeProperty.intValue            = (int)objectType;
            fullTypeNameProperty.stringValue = assemblyQualifiedName;
            serializedObject.ApplyModifiedProperties();

            switch (objectType)
            {
            case ObjectType.Bounds:
            case ObjectType.Rect:
            case ObjectType.Matrix4x4:
            case ObjectType.SerializableType:
            case ObjectType.Array:
            case ObjectType.List:
                if (GUI.Button(rect, WIZARD))
                {
                    var wizard = ScriptableWizard.DisplayWizard <PropertyWizard>(string.Empty, "Save");
                    wizard.infos              = infos;
                    wizard.type               = objectType;
                    wizard.typeOf             = Type.GetType(assemblyQualifiedName);
                    wizard.serializedProperty = fieldProp;
                    wizard.path               = fieldProp.propertyPath;
                    wizard.onClose            = OnPropertyWizardClose;
                }
                return;
            }

            var label = new GUIContent(typeName);

            switch (objectType)
            {
            case ObjectType.Boolean:
            case ObjectType.Int32:
            case ObjectType.Int64:
            case ObjectType.Single:
            case ObjectType.Double:
            case ObjectType.String:
                EditorGUI.PropertyField(rect, fieldProp, label, false);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.UInt64:
                var   oldValue    = fieldProp.stringValue;
                var   ulongString = EditorGUI.TextField(rect, label, fieldProp.stringValue);
                ulong ulongVal;

                if (!ulong.TryParse(ulongString, out ulongVal))
                {
                    ulongString = oldValue;
                }

                if (string.IsNullOrEmpty(ulongString))
                {
                    ulongString = "0";
                }

                fieldProp.stringValue = ulongString;
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.LayerMask:
            case ObjectType.Color:
            case ObjectType.AnimationCurve:
                EditorGUI.PropertyField(rect, fieldProp, GUIContent.none, false);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.Byte:
                fieldProp.intValue = EditorFields.ByteField(rect, label, (byte)fieldProp.intValue);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.SByte:
                fieldProp.intValue = EditorFields.SByteField(rect, label, (sbyte)fieldProp.intValue);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.Char:
                fieldProp.intValue = EditorFields.CharField(rect, label, (char)fieldProp.intValue);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.Int16:
                fieldProp.intValue = EditorFields.ShortField(rect, label, (short)fieldProp.intValue);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.UInt16:
                fieldProp.intValue = EditorFields.UShortField(rect, label, (ushort)fieldProp.intValue);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.UInt32:
                fieldProp.longValue = EditorFields.UIntField(rect, label, (uint)fieldProp.longValue);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.Enum:
            {
                var  typeOf         = Type.GetType(assemblyQualifiedName);
                var  flagsAttribute = typeOf.GetCustomAttributes(typeof(FlagsAttribute), false);
                Enum enumValue;

                if (flagsAttribute != null && flagsAttribute.Length >= 1)
                {
                    enumValue = EditorGUI.EnumMaskPopup(rect, GUIContent.none, (Enum)Enum.ToObject(typeOf, fieldProp.longValue));
                }
                else
                {
                    enumValue = EditorGUI.EnumPopup(rect, (Enum)Enum.ToObject(typeOf, fieldProp.longValue));
                }

                try
                {
                    fieldProp.longValue = (int)Enum.ToObject(typeOf, enumValue);
                    serializedObject.ApplyModifiedProperties();
                }
                catch
                {
                    fieldProp.longValue = (long)Enum.ToObject(typeOf, enumValue);
                    serializedObject.ApplyModifiedProperties();
                }
            }
            break;

            case ObjectType.Vector2:
                fieldProp.vector2Value = EditorGUI.Vector2Field(rect, GUIContent.none, fieldProp.vector2Value);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.Vector3:
                fieldProp.vector3Value = EditorGUI.Vector3Field(rect, GUIContent.none, fieldProp.vector3Value);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.Vector4:
                fieldProp.vector4Value = EditorGUI.Vector4Field(rect, GUIContent.none, fieldProp.vector4Value);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.Quaternion:
                fieldProp.quaternionValue = EditorFields.QuaternionField(rect, GUIContent.none, fieldProp.quaternionValue);
                serializedObject.ApplyModifiedProperties();
                break;

            case ObjectType.UnityObject:
            {
                var typeOf = Type.GetType(assemblyQualifiedName);
                fieldProp.objectReferenceValue = EditorGUI.ObjectField(rect, GUIContent.none, fieldProp.objectReferenceValue, typeOf, true);
                serializedObject.ApplyModifiedProperties();
            }
            break;
            }
        }
 public void ApplyChanges()
 {
     m_SerializedObject.ApplyModifiedProperties();
     m_SerializedObject.Update();
 }
Exemplo n.º 20
0
 protected void Apply()
 {
     SerializedObject.ApplyModifiedProperties();
 }
Exemplo n.º 21
0
 internal void Apply()
 {
     m_SerializedObject.ApplyModifiedProperties();
 }
Exemplo n.º 22
0
        public static void SetupBaseUnlitKeywords(this Material material)
        {
            // First thing, be sure to have an up to date RenderQueue
            material.ResetMaterialCustomRenderQueue();

            bool alphaTestEnable = material.HasProperty(kAlphaCutoffEnabled) && material.GetFloat(kAlphaCutoffEnabled) > 0.0f;

            CoreUtils.SetKeyword(material, "_ALPHATEST_ON", alphaTestEnable);

            // Setup alpha to mask using the _AlphaToMaskInspectorValue that we configure in the material UI
            float alphaToMaskEnabled = material.HasProperty("_AlphaToMaskInspectorValue") && material.GetFloat("_AlphaToMaskInspectorValue") > 0.0 ? 1 : 0;

            material.SetFloat(kAlphaToMask, alphaTestEnable ? alphaToMaskEnabled : 0);

            bool alphaToMaskEnable = alphaTestEnable && material.HasProperty(kAlphaToMask) && material.GetFloat(kAlphaToMask) > 0.0f;

            CoreUtils.SetKeyword(material, "_ALPHATOMASK_ON", alphaToMaskEnable);

            SurfaceType surfaceType = material.GetSurfaceType();

            CoreUtils.SetKeyword(material, "_SURFACE_TYPE_TRANSPARENT", surfaceType == SurfaceType.Transparent);

            bool transparentWritesMotionVec = (surfaceType == SurfaceType.Transparent) && material.HasProperty(kTransparentWritingMotionVec) && material.GetInt(kTransparentWritingMotionVec) > 0;

            CoreUtils.SetKeyword(material, "_TRANSPARENT_WRITES_MOTION_VEC", transparentWritesMotionVec);

            if (material.HasProperty(kAddPrecomputedVelocity))
            {
                CoreUtils.SetKeyword(material, "_ADD_PRECOMPUTED_VELOCITY", material.GetInt(kAddPrecomputedVelocity) != 0);
            }

            HDRenderQueue.RenderQueueType renderQueueType = HDRenderQueue.GetTypeByRenderQueueValue(material.renderQueue);
            bool needOffScreenBlendFactor = renderQueueType == HDRenderQueue.RenderQueueType.AfterPostprocessTransparent || renderQueueType == HDRenderQueue.RenderQueueType.LowTransparent;

            // Alpha tested materials always have a prepass where we perform the clip.
            // Then during Gbuffer pass we don't perform the clip test, so we need to use depth equal in this case.
            if (alphaTestEnable)
            {
                material.SetInt(kZTestGBuffer, (int)UnityEngine.Rendering.CompareFunction.Equal);
            }
            else
            {
                material.SetInt(kZTestGBuffer, (int)UnityEngine.Rendering.CompareFunction.LessEqual);
            }

            // If the material use the kZTestDepthEqualForOpaque it mean it require depth equal test for opaque but transparent are not affected
            if (material.HasProperty(kZTestDepthEqualForOpaque))
            {
                if (surfaceType == SurfaceType.Opaque)
                {
                    // When the material is after post process, we need to use LEssEqual because there is no depth prepass for unlit opaque
                    if (HDRenderQueue.k_RenderQueue_AfterPostProcessOpaque.Contains(material.renderQueue))
                    {
                        material.SetInt(kZTestDepthEqualForOpaque, (int)UnityEngine.Rendering.CompareFunction.LessEqual);
                    }
                    else
                    {
                        material.SetInt(kZTestDepthEqualForOpaque, (int)UnityEngine.Rendering.CompareFunction.Equal);
                    }
                }
                else
                {
                    material.SetInt(kZTestDepthEqualForOpaque, (int)material.GetTransparentZTest());
                }
            }

            if (surfaceType == SurfaceType.Opaque)
            {
                material.SetOverrideTag("RenderType", alphaTestEnable ? "TransparentCutout" : "");
                material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
                // Caution:  we need to setup One for src and Zero for Dst for all element as users could switch from transparent to Opaque and keep remaining value.
                // Unity will disable Blending based on these default value.
                // Note that for after postprocess we setup 0 in opacity inside the shaders, so we correctly end with 0 in opacity for the compositing pass
                material.SetInt("_AlphaSrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                material.SetInt("_AlphaDstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
                material.SetInt(kZWrite, 1);
            }
            else
            {
                material.SetOverrideTag("RenderType", "Transparent");
                material.SetInt(kZWrite, material.GetTransparentZWrite() ? 1 : 0);

                if (material.HasProperty(kBlendMode))
                {
                    BlendMode blendMode = material.GetBlendMode();

                    // When doing off-screen transparency accumulation, we change blend factors as described here: https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch23.html
                    switch (blendMode)
                    {
                    // Alpha
                    // color: src * src_a + dst * (1 - src_a)
                    // src * src_a is done in the shader as it allow to reduce precision issue when using _BLENDMODE_PRESERVE_SPECULAR_LIGHTING (See Material.hlsl)
                    case BlendMode.Alpha:
                        material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                        material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                        if (needOffScreenBlendFactor)
                        {
                            material.SetInt("_AlphaSrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
                            material.SetInt("_AlphaDstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                        }
                        else
                        {
                            material.SetInt("_AlphaSrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                            material.SetInt("_AlphaDstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                        }
                        break;

                    // Additive
                    // color: src * src_a + dst
                    // src * src_a is done in the shader
                    case BlendMode.Additive:
                        material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                        material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
                        if (needOffScreenBlendFactor)
                        {
                            material.SetInt("_AlphaSrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
                            material.SetInt("_AlphaDstBlend", (int)UnityEngine.Rendering.BlendMode.One);
                        }
                        else
                        {
                            material.SetInt("_AlphaSrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                            material.SetInt("_AlphaDstBlend", (int)UnityEngine.Rendering.BlendMode.One);
                        }
                        break;

                    // PremultipliedAlpha
                    // color: src * src_a + dst * (1 - src_a)
                    // src is supposed to have been multiplied by alpha in the texture on artists side.
                    case BlendMode.Premultiply:
                        material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                        material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                        if (needOffScreenBlendFactor)
                        {
                            material.SetInt("_AlphaSrcBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
                            material.SetInt("_AlphaDstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                        }
                        else
                        {
                            material.SetInt("_AlphaSrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                            material.SetInt("_AlphaDstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                        }
                        break;
                    }
                }
            }

            bool fogEnabled = material.HasProperty(kEnableFogOnTransparent) && material.GetFloat(kEnableFogOnTransparent) > 0.0f && surfaceType == SurfaceType.Transparent;

            CoreUtils.SetKeyword(material, "_ENABLE_FOG_ON_TRANSPARENT", fogEnabled);

            if (material.HasProperty(kDistortionEnable) && material.HasProperty(kDistortionBlendMode))
            {
                bool distortionDepthTest = material.GetFloat(kDistortionDepthTest) > 0.0f;
                if (material.HasProperty(kZTestModeDistortion))
                {
                    if (distortionDepthTest)
                    {
                        material.SetInt(kZTestModeDistortion, (int)UnityEngine.Rendering.CompareFunction.LessEqual);
                    }
                    else
                    {
                        material.SetInt(kZTestModeDistortion, (int)UnityEngine.Rendering.CompareFunction.Always);
                    }
                }

                var distortionBlendMode = material.GetInt(kDistortionBlendMode);
                switch (distortionBlendMode)
                {
                default:
                case 0:     // Add
                    material.SetInt("_DistortionSrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                    material.SetInt("_DistortionDstBlend", (int)UnityEngine.Rendering.BlendMode.One);

                    material.SetInt("_DistortionBlurSrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                    material.SetInt("_DistortionBlurDstBlend", (int)UnityEngine.Rendering.BlendMode.One);
                    material.SetInt("_DistortionBlurBlendOp", (int)UnityEngine.Rendering.BlendOp.Add);
                    break;

                case 1:     // Multiply
                    material.SetInt("_DistortionSrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
                    material.SetInt("_DistortionDstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);

                    material.SetInt("_DistortionBlurSrcBlend", (int)UnityEngine.Rendering.BlendMode.DstAlpha);
                    material.SetInt("_DistortionBlurDstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
                    material.SetInt("_DistortionBlurBlendOp", (int)UnityEngine.Rendering.BlendOp.Add);
                    break;

                case 2:     // Replace
                    material.SetInt("_DistortionSrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                    material.SetInt("_DistortionDstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);

                    material.SetInt("_DistortionBlurSrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
                    material.SetInt("_DistortionBlurDstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
                    material.SetInt("_DistortionBlurBlendOp", (int)UnityEngine.Rendering.BlendOp.Add);
                    break;
                }
            }

            CullMode doubleSidedOffMode = (surfaceType == SurfaceType.Transparent) ? material.GetTransparentCullMode() : material.GetOpaqueCullMode();

            bool isBackFaceEnable  = material.HasProperty(kTransparentBackfaceEnable) && material.GetFloat(kTransparentBackfaceEnable) > 0.0f && surfaceType == SurfaceType.Transparent;
            bool doubleSidedEnable = material.HasProperty(kDoubleSidedEnable) && material.GetFloat(kDoubleSidedEnable) > 0.0f;

            DoubleSidedGIMode doubleSidedGIMode = DoubleSidedGIMode.Auto;

            if (material.HasProperty(kDoubleSidedGIMode))
            {
                doubleSidedGIMode = (DoubleSidedGIMode)material.GetFloat(kDoubleSidedGIMode);
            }

            // Disable culling if double sided
            material.SetInt("_CullMode", doubleSidedEnable ? (int)UnityEngine.Rendering.CullMode.Off : (int)doubleSidedOffMode);

            // We have a separate cullmode (_CullModeForward) for Forward in case we use backface then frontface rendering, need to configure it
            if (isBackFaceEnable)
            {
                material.SetInt("_CullModeForward", (int)UnityEngine.Rendering.CullMode.Back);
            }
            else
            {
                material.SetInt("_CullModeForward", (int)(doubleSidedEnable ? UnityEngine.Rendering.CullMode.Off : doubleSidedOffMode));
            }

            CoreUtils.SetKeyword(material, "_DOUBLESIDED_ON", doubleSidedEnable);

            // A material's GI flag internally keeps track of whether emission is enabled at all, it's enabled but has no effect
            // or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color.
            // The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color.
            if (material.HasProperty(kEmissionColor))
            {
                material.SetColor(kEmissionColor, Color.white); // kEmissionColor must always be white to allow our own material to control the GI (this allow to fallback from builtin unity to our system).
                                                                // as it happen with old material that it isn't the case, we force it.
                MaterialEditor.FixupEmissiveFlag(material);
            }

            material.SetupMainTexForAlphaTestGI("_UnlitColorMap", "_UnlitColor");

            // depth offset for ShaderGraphs (they don't have the displacement mode property)
            if (!material.HasProperty(kDisplacementMode) && material.HasProperty(kDepthOffsetEnable))
            {
                // Depth offset is only enabled if per pixel displacement is
                bool depthOffsetEnable = (material.GetFloat(kDepthOffsetEnable) > 0.0f);
                CoreUtils.SetKeyword(material, "_DEPTHOFFSET_ON", depthOffsetEnable);
            }

            // DoubleSidedGI has to be synced with our double sided toggle
            var  serializedObject = new SerializedObject(material);
            bool doubleSidedGI    = false;

            if (doubleSidedGIMode == DoubleSidedGIMode.Auto)
            {
                doubleSidedGI = doubleSidedEnable;
            }
            else if (doubleSidedGIMode == DoubleSidedGIMode.On)
            {
                doubleSidedGI = true;
            }
            else if (doubleSidedGIMode == DoubleSidedGIMode.Off)
            {
                doubleSidedGI = false;
            }
            // material always call setdirty, so set only if new value is different
            if (doubleSidedGI != material.doubleSidedGI)
            {
                material.doubleSidedGI = doubleSidedGI;
            }
            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 23
0
    public override void OnInspectorGUI()
    {
        CombineChildrenAFS = new SerializedObject(target);
        GetProperties();
        CombineChildrenAFS script = (CombineChildrenAFS)target;

        Color myBlue = new Color(0.5f, 0.7f, 1.0f, 1.0f);
        Color myCol  = new Color(.5f, .8f, .0f, 1f);        // Light Green

        if (!EditorGUIUtility.isProSkin)
        {
            myCol = new Color(0.05f, 0.45f, 0.0f, 1.0f);          // Dark Green
        }


        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);

        myFoldoutStyle.fontStyle = FontStyle.Bold;

        myFoldoutStyle.normal.textColor   = myCol;
        myFoldoutStyle.onNormal.textColor = myCol;              //	Rendering settings for when the control is turned on but lost focus
        //myFoldoutStyle.hover.textColor = Color.white;
        //myFoldoutStyle.onHover.textColor = Color.white;
        myFoldoutStyle.active.textColor    = myCol;
        myFoldoutStyle.onActive.textColor  = myCol;
        myFoldoutStyle.focused.textColor   = myCol;
        myFoldoutStyle.onFocused.textColor = myCol;

        GUIStyle myBoldLabel = new GUIStyle(EditorStyles.label);

        myBoldLabel.fontStyle          = FontStyle.Bold;
        myBoldLabel.normal.textColor   = myCol;
        myBoldLabel.onNormal.textColor = myCol;


        //
        if (script.isStaticallyCombined)
        {
            GUI.enabled = false;
        }
        //

        EditorGUILayout.BeginVertical();
        GUILayout.Space(10);


        EditorGUI.BeginChangeCheck();
        EditorGUILayout.BeginHorizontal();
        script.hideChildren = EditorGUILayout.Toggle("", script.hideChildren, GUILayout.Width(14));
        GUILayout.Label("Hide Child Objects in Hierarchy");
        EditorGUILayout.EndHorizontal();


        if (EditorGUI.EndChangeCheck())
        {
            script.ShowHideChildren();
        }


        //	GUI.color = myCol;
        GUILayout.Label("Ground normal sampling", myBoldLabel);          //EditorStyles.boldLabel);
        //	GUI.color = Color.white;
        GUILayout.Space(4);
        EditorGUILayout.PropertyField(GroundMaxDistance, new GUIContent("Max Ground Distance"));
        GUILayout.Space(4);
        // underlaying terrain
        //script.UnderlayingTerrain = (Terrain)EditorGUILayout.ObjectField("Underlaying Terrain", script.UnderlayingTerrain, typeof(Terrain), true);
        EditorGUILayout.PropertyField(UnderlayingTerrain, new GUIContent("Underlaying Terrain"));
        GUI.color = myBlue;
        hTerrain  = EditorGUILayout.Foldout(hTerrain, " Help");
        GUI.color = Color.white;
        if (hTerrain)
        {
            EditorGUILayout.HelpBox("If you place the objects of the cluster (all or just a few of them) on top of a terrain you will have to assign the according terrain in order to make lighting fit 100% the terrain lighting.", MessageType.None, true);
        }

        // bake grass
        GUILayout.Space(9);
        EditorGUILayout.BeginVertical();
        //	GUI.color = myCol;
        //script.bakeGroundLigthingGrass = EditorGUILayout.Toggle("", script.bakeGroundLigthingGrass, GUILayout.Width(14) );
        sGrass = EditorGUILayout.Foldout(sGrass, " Grass Shader Settings", myFoldoutStyle);
        //	GUI.color = Color.white;
        GUILayout.Space(4);

        if (sGrass)
        {
            EditorGUILayout.PropertyField(HealthyColor, new GUIContent("Healthy Color"));
            EditorGUILayout.PropertyField(DryColor, new GUIContent("Dry Color"));
            EditorGUILayout.PropertyField(NoiseSpread, new GUIContent("Noise Spread"));
        }
        EditorGUILayout.EndVertical();

        // bake foliage
        GUILayout.Space(9);
        EditorGUILayout.BeginVertical();
        //script.bakeGroundLightingFoliage = EditorGUILayout.Toggle("", script.bakeGroundLightingFoliage, GUILayout.Width(14) );
        //GUI.color = myCol;
        sFoliage = EditorGUILayout.Foldout(sFoliage, " Foliage Shader Settings", myFoldoutStyle);
        //GUI.color = Color.white;
        GUILayout.Space(4);
        if (sFoliage)
        {
            EditorGUILayout.PropertyField(randomBrightness, new GUIContent("Random Brightness"));
            EditorGUILayout.PropertyField(randomPulse, new GUIContent("Random Pulse"));
            EditorGUILayout.PropertyField(randomBending, new GUIContent("Random Bending"));
            EditorGUILayout.PropertyField(randomFluttering, new GUIContent("Random Fluttering"));
            EditorGUILayout.PropertyField(NoiseSpreadFoliage, new GUIContent("Noise Spread"));
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(bakeScale, GUIContent.none, GUILayout.Width(14));
            GUILayout.Label("Bake Scale");
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();

        // overall settings
        GUILayout.Space(9);
        //GUI.color = myCol;
        GUILayout.Label("Overall Settings", myBoldLabel);
        //GUI.color = Color.white;
        GUILayout.Space(4);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginHorizontal();
        script.CastShadows = EditorGUILayout.Toggle("", script.CastShadows, GUILayout.Width(14));
        GUILayout.Label("Cast Shadows");
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(4);
        EditorGUILayout.BeginHorizontal();
        script.destroyChildObjectsInPlaymode = EditorGUILayout.Toggle("", script.destroyChildObjectsInPlaymode, GUILayout.Width(14));
        GUILayout.Label("Destroy Children");
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(4);
        EditorGUILayout.BeginHorizontal();
        script.UseLightprobes = EditorGUILayout.Toggle("", script.UseLightprobes, GUILayout.Width(14));
        GUILayout.Label("Use Lightprobes");
        EditorGUILayout.EndHorizontal();
        //if (script.UseLightprobes) {
        //	EditorGUILayout.HelpBox("Please make sure that 'Enable IBL' is disabled in the 'Setup Advanced Foliage Shader' script. Otherwise Lightprobes are not supported.", MessageType.Warning, true);
        //}
        GUILayout.Space(4);
        //if (script.destroyChildObjectsInPlaymode) {
        //	EditorGUILayout.BeginHorizontal();
        //	GUILayout.Label ("", GUILayout.Width(16) );
        //	EditorGUILayout.HelpBox("If this option is checked, child objects will also be destroyed if you hit 'Combine statically'.", MessageType.Warning, true);
        //	EditorGUILayout.EndHorizontal();
        //}



        // debugging settings
        GUILayout.Space(9);
        //GUI.color = myCol;
        GUILayout.Label("Debugging", myBoldLabel);
        //GUI.color = Color.white;
        GUILayout.Space(4);
        EditorGUILayout.BeginHorizontal();
        script.debugNormals = EditorGUILayout.Toggle("", script.debugNormals, GUILayout.Width(14));
        GUILayout.Label("Debug sampled Ground Normals");
        EditorGUILayout.EndHorizontal();
        if (script.debugNormals)
        {
            script.EnableDebugging();
        }
        else
        {
            script.DisableDebugging();
        }


        // functions
        GUILayout.Space(9);
        //GUI.color = myCol;
        GUILayout.Label("Functions", myBoldLabel);
        //GUI.color = Color.white;
        GUILayout.Space(4);
        script.RealignGroundMaxDistance = EditorGUILayout.Slider("Realign Ground max Dist.", script.RealignGroundMaxDistance, 0.0f, 10.0f);
        EditorGUILayout.BeginHorizontal();
        script.ForceRealignment = EditorGUILayout.Toggle("", script.ForceRealignment, GUILayout.Width(14));
        GUILayout.Label("Force Realignment");
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(9);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Realign Objects"))
        {
            script.Realign();
        }
        if (GUILayout.Button("Combine statically"))
        {
            if (script.destroyChildObjectsInPlaymode)
            {
                if (EditorUtility.DisplayDialog("Combine statically?", "Are you sure you want to combine and destroy all child objects? If you want to be able to edit child objects please uncheck 'Destroy Children' first.", "Combine", "Do not Combine"))
                {
                    script.Combine();
                }
            }
            else
            {
                if (EditorUtility.DisplayDialog("Combine statically?", "All child objects will be deactivated.", "Combine", "Do not Combine"))
                {
                    script.Combine();
                }
            }
        }
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(9);

        EditorGUILayout.BeginHorizontal();
        script.createUniqueUV2 = EditorGUILayout.Toggle("", script.createUniqueUV2, GUILayout.Width(14));
        GUILayout.Label("Create unique UV2 (needed by lightmapper)");
        EditorGUILayout.EndHorizontal();

        GUI.enabled = true;

        EditorGUILayout.BeginHorizontal();
        script.isStaticallyCombined = EditorGUILayout.Toggle("", script.isStaticallyCombined, GUILayout.Width(14));
        GUILayout.Label("Has been statically combined");
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(9);
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            //script.Update();
            EditorUtility.SetDirty(script);
            SceneView.RepaintAll();
        }
        CombineChildrenAFS.ApplyModifiedProperties();
    }
Exemplo n.º 24
0
 /// <summary>
 ///     Mark SerializedObject as changed + mark scene as changed
 /// </summary>
 /// <param name="object"></param>
 public static void MarkAsDirty(SerializedObject @object = null)
 {
     @object?.ApplyModifiedProperties();
     EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
 }
Exemplo n.º 25
0
        void OnGUI()
        {
            if (m_style == null)
            {
                m_style = new EditorStyle();
                m_style.SetupStyle();
            }

            GUI.enabled = m_idle;
            EditorGUILayout.BeginVertical(m_style.GreyBox);
            m_style.DrawTitleBar("Required component (Motion Controller)");

            if (m_controller == null)
            {
                m_controller = (MotionController)EditorGUILayout.ObjectField(m_controller, typeof(MotionController), true);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                GUI.enabled = false;
                EditorGUILayout.ObjectField(m_controller, typeof(MotionController), true);
                GUI.enabled = m_idle;
                if (GUILayout.Button("Unlock"))
                {
                    RemoveController();
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();

            if (m_controller == null)
            {
                Clips              = null;
                m_originalPos      = null;
                m_originalRot      = null;
                m_selectedPoseBase = 0;
                EditorGUILayout.HelpBox("Before setting up animations you must set all the required components, right now you are missing the Motion Controller component.", MessageType.Error);
                return;
            }

            if (!m_controller.Ready)
            {
                Clips = null;
                EditorGUILayout.HelpBox("Before setting up animations you must setup the Root bone and Legs of your Motion Controller.", MessageType.Error);
                return;
            }

            if (m_controller.Animator == null)
            {
                Clips = null;
                EditorGUILayout.HelpBox("The selected MotionController has no Animator component defined.", MessageType.Error);
                return;
            }

            if (m_controller.Animator.runtimeAnimatorController == null)
            {
                Clips = null;
                EditorGUILayout.HelpBox("The selected Animator GameObject has no AnimatorController.", MessageType.Error);
                return;
            }

            m_animator = m_controller.Animator;
            if (m_animator.avatar == null)
            {
                Clips = null;
                EditorGUILayout.HelpBox("The selected Animator GameObject has no Avatar.", MessageType.Error);
                return;
            }

            var rCtrl = m_animator.runtimeAnimatorController;

            if (rCtrl.animationClips == null || rCtrl.animationClips.Length == 0)
            {
                m_list = null;
                EditorGUILayout.HelpBox("AnimatorController has no animations, it should not be empty.", MessageType.Error);
                return;
            }

            m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, false, false);
            EditorGUILayout.BeginVertical(m_style.GreyBox);
            m_style.DrawTitleBar("Animations from Animator Controller");

            if (Clips == null || Clips.Length == 0)
            {
                var clips = rCtrl.animationClips;
                Clips            = new MotionClip[clips.Length];
                m_animationPoses = new string[clips.Length];

                for (int i = 0; i < clips.Length; i++)
                {
                    var clip = clips[i];
                    m_animationPoses[i] = clip.name;

                    var m = new MotionClip()
                    {
                        Clip           = clip,
                        Id             = clip.GetInstanceID(),
                        Name           = clip.name,
                        FixFootSkating = false,
                    };
                    var nm = clip.name.ToLower();
                    if (nm.Contains("stand") || nm.Contains("idle"))
                    {
                        m.Stationary     = true;
                        m.FixFootSkating = true;
                    }

                    if (nm.Contains("walk") || nm.Contains("run") || nm.Contains("sprint") || nm.Contains("strafe"))
                    {
                        m.Stationary = false;
                    }

                    Clips[i] = m;
                }
            }

            m_so.Update();
            m_list.DoLayoutList();
            m_so.ApplyModifiedProperties();

            m_style.DrawTitleBar("Animation analisis");
            m_ignoreRootMotion = (IgnoreRootMotionOnBone)EditorGUILayout.EnumPopup("Ignore Root motion", m_ignoreRootMotion);
            m_selectedPoseBase = EditorGUILayout.Popup("Standing pose", m_selectedPoseBase, m_animationPoses);
            m_samples          = EditorGUILayout.IntSlider("Samples", m_samples, Int.Ten, Int.OneHundred);//EditorGUI.IntSlider(EditorGUILayout.GetControlRect(false, m_progHeight), "Samples", m_samples, Int.Ten, Int.OneHundred);

            if (m_idle)
            {
                if (!Clips[m_selectedPoseBase].Stationary)
                {
                    EditorGUILayout.HelpBox("Selected Standing pose is not Stationary.", MessageType.Error);
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Start analisis"))
                    {
                        StartProcess();
                    }
                    if (MotionAsset == null || MotionAsset.MotionCount == Int.Zero)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Save data"))
                    {
                        SaveAsset();
                    }

                    GUI.enabled = m_idle;
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                ProcessAnimation();
                string clipName;
                if (m_currentAnimation > -Int.One)
                {
                    clipName = Clips[m_currentAnimation].Name;
                }
                else
                {
                    clipName = Clips[Int.Zero].Name;
                }

                GUI.enabled = true;
                var prog = m_progress * Float.OneHundred;
                var sts  = prog.ToString("0") + "% " + clipName;
                if (m_progress >= Float.One)
                {
                    EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(false, m_progHeight), m_progress, "Done");
                }
                else
                {
                    EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(false, m_progHeight), m_progress, sts);
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();

            if (!m_idle && (m_uiDelay != m_lastUIDelay))
            {
                m_lastUIDelay = m_uiDelay;
                Repaint();
            }

            if (!m_idle && m_currentAnimation == (Clips.Length - Int.One))
            {
                m_uiDelay += Float.DotOne;
                if (m_uiDelay < Float.One)
                {
                    return;
                }

                m_idle = true;
                FinishAnalisis();
                SaveAsset();
                return;
            }

            if (m_reset)
            {
                MotionAsset = null;
                m_reset     = false;
            }
        }
Exemplo n.º 26
0
        public override void EditMenu()
        {
            SerializedObject serializedObject = new SerializedObject(settings);

            if (this.GetType() == typeof(SimulatedLinearTreadmill))
            {
                ControllerMenuTitle(settings.isActive, "Simulated Linear Treadmill");
                EditorGUILayout.LabelField("Device", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;
                // Select controller.
                EditorGUILayout.BeginHorizontal(LayoutSettings.editFieldOp);
                if (EditorApplication.isPlaying)
                {
                    GUI.enabled = false;
                }
                if (settings.gamepadSettings.selectedGamepad >= deviceNames.Length)
                {
                    settings.gamepadSettings.selectedGamepad = 0;
                }
                settings.gamepadSettings.selectedGamepad = EditorGUILayout.Popup(settings.gamepadSettings.selectedGamepad, deviceNames);
                if (GUILayout.Button("Rescan Devices"))
                {
                    deviceNames = Gamepad.GetDeviceNames();
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.PropertyField(serializedObject.FindProperty("buttonTopics"), true);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("isActive"), new GUIContent("Active"), LayoutSettings.editFieldOp);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("enableLogging"), new GUIContent("Log Input"), LayoutSettings.editFieldOp);
                EditorGUI.indentLevel--;
                GUI.enabled = true;
            }
            else
            {
                ControllerMenuTitle(settings.isActive, "Linear Treadmill");
                EditorGUILayout.LabelField("Device", EditorStyles.boldLabel);
                if (EditorApplication.isPlaying)
                {
                    GUI.enabled = false;
                }
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(serializedObject.FindProperty("isActive"), new GUIContent("Active"), LayoutSettings.editFieldOp);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("deviceName"), new GUIContent("MQTT Name"), LayoutSettings.editFieldOp);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("deviceIsSpherical"), new GUIContent("Spherical Treadmill"), LayoutSettings.editFieldOp);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("enableLogging"), new GUIContent("Log Input"), true, LayoutSettings.editFieldOp);
                EditorGUI.indentLevel--;
                GUI.enabled = true;
            }
            // Movement settings.
            EditorGUILayout.LabelField("Movement Settings", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(serializedObject.FindProperty("gain"), true, LayoutSettings.editFieldOp);
            EditorGUILayout.BeginHorizontal(LayoutSettings.editFieldOp); EditorGUILayout.PropertyField(serializedObject.FindProperty("inputSmooth"), new GUIContent("Input Smoothing")); EditorGUILayout.LabelField("(ms)", GUILayout.Width(70)); EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel--;
            serializedObject.ApplyModifiedProperties();
            // Path settings.
            EditorGUILayout.LabelField("Paths", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            Undo.RecordObject(this, "Change Controller Path");
            path = (PathCreation.PathCreator)EditorGUILayout.ObjectField("Selected Path", path, typeof(PathCreation.PathCreator), true, LayoutSettings.editFieldOp);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("loopPath"), true, LayoutSettings.editFieldOp);
            serializedObject.ApplyModifiedProperties();
            EditorGUI.indentLevel--;
        }
Exemplo n.º 27
0
        public override void OnInspectorGUI()
        {
            serObj.Update();

            waterBase = (WaterBase)serObj.targetObject;
            oceanBase = ((WaterBase)serObj.targetObject).gameObject;
            if (!oceanBase)
            {
                return;
            }

            GUILayout.Label("This script helps adjusting water material properties", EditorStyles.miniBoldLabel);

            EditorGUILayout.PropertyField(sharedMaterial, new GUIContent("Material"));
            oceanMaterial = (Material)sharedMaterial.objectReferenceValue;

            if (!oceanMaterial)
            {
                sharedMaterial.objectReferenceValue = (Object)WaterEditorUtility.LocateValidWaterMaterial(oceanBase.transform);
                serObj.ApplyModifiedProperties();
                oceanMaterial = (Material)sharedMaterial.objectReferenceValue;
                if (!oceanMaterial)
                {
                    return;
                }
            }

            EditorGUILayout.Separator();

            GUILayout.Label("Overall Quality", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(waterQuality, new GUIContent("Quality"));
            EditorGUILayout.PropertyField(edgeBlend, new GUIContent("Edge blend?"));

            if (waterQuality.intValue > (int)WaterQuality.Low)
            {
                EditorGUILayout.HelpBox("Water features not supported", MessageType.Warning);
            }
            if (edgeBlend.boolValue && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
            {
                EditorGUILayout.HelpBox("Edge blend not supported", MessageType.Warning);
            }

            EditorGUILayout.Separator();

            bool hasShore = oceanMaterial.HasProperty("_ShoreTex");

            GUILayout.Label("Main Colors", EditorStyles.boldLabel);
            GUILayout.Label("Alpha values define blending with realtime textures", EditorStyles.miniBoldLabel);

            WaterEditorUtility.SetMaterialColor("_BaseColor", EditorGUILayout.ColorField("Refraction", WaterEditorUtility.GetMaterialColor("_BaseColor", oceanMaterial)), oceanMaterial);
            WaterEditorUtility.SetMaterialColor("_ReflectionColor", EditorGUILayout.ColorField("Reflection", WaterEditorUtility.GetMaterialColor("_ReflectionColor", oceanMaterial)), oceanMaterial);

            EditorGUILayout.Separator();

            GUILayout.Label("Main Textures", EditorStyles.boldLabel);
            GUILayout.Label("Used for small waves (bumps), foam and white caps", EditorStyles.miniBoldLabel);

            WaterEditorUtility.SetMaterialTexture("_BumpMap", (Texture)EditorGUILayout.ObjectField("Normals", WaterEditorUtility.GetMaterialTexture("_BumpMap", waterBase.sharedMaterial), typeof(Texture), false), waterBase.sharedMaterial);
            if (hasShore)
            {
                WaterEditorUtility.SetMaterialTexture("_ShoreTex", (Texture)EditorGUILayout.ObjectField("Shore & Foam", WaterEditorUtility.GetMaterialTexture("_ShoreTex", waterBase.sharedMaterial), typeof(Texture), false), waterBase.sharedMaterial);
            }

            Vector4 animationTiling;
            Vector4 animationDirection;

            Vector2 firstTiling;
            Vector2 secondTiling;
            Vector2 firstDirection;
            Vector2 secondDirection;

            animationTiling    = WaterEditorUtility.GetMaterialVector("_BumpTiling", oceanMaterial);
            animationDirection = WaterEditorUtility.GetMaterialVector("_BumpDirection", oceanMaterial);

            firstTiling  = new Vector2(animationTiling.x * 100.0F, animationTiling.y * 100.0F);
            secondTiling = new Vector2(animationTiling.z * 100.0F, animationTiling.w * 100.0F);

            firstTiling  = EditorGUILayout.Vector2Field("Tiling 1", firstTiling);
            secondTiling = EditorGUILayout.Vector2Field("Tiling 2", secondTiling);

            //firstTiling.x = EditorGUILayout.FloatField("1st Tiling U", firstTiling.x);
            //firstTiling.y = EditorGUILayout.FloatField("1st Tiling V", firstTiling.y);
            //secondTiling.x = EditorGUILayout.FloatField("2nd Tiling U", secondTiling.x);
            //secondTiling.y = EditorGUILayout.FloatField("2nd Tiling V", secondTiling.y);

            firstDirection  = new Vector2(animationDirection.x, animationDirection.y);
            secondDirection = new Vector2(animationDirection.z, animationDirection.w);

            //firstDirection.x = EditorGUILayout.FloatField("1st Animation U", firstDirection.x);
            //firstDirection.y = EditorGUILayout.FloatField("1st Animation V", firstDirection.y);
            //secondDirection.x = EditorGUILayout.FloatField("2nd Animation U", secondDirection.x);
            //secondDirection.y = EditorGUILayout.FloatField("2nd Animation V", secondDirection.y);

            firstDirection  = EditorGUILayout.Vector2Field("Direction 1", firstDirection);
            secondDirection = EditorGUILayout.Vector2Field("Direction 2", secondDirection);

            animationTiling    = new Vector4(firstTiling.x / 100.0F, firstTiling.y / 100.0F, secondTiling.x / 100.0F, secondTiling.y / 100.0F);
            animationDirection = new Vector4(firstDirection.x, firstDirection.y, secondDirection.x, secondDirection.y);

            WaterEditorUtility.SetMaterialVector("_BumpTiling", animationTiling, oceanMaterial);
            WaterEditorUtility.SetMaterialVector("_BumpDirection", animationDirection, oceanMaterial);

            Vector4 displacementParameter = WaterEditorUtility.GetMaterialVector("_DistortParams", oceanMaterial);
            Vector4 fade = WaterEditorUtility.GetMaterialVector("_InvFadeParemeter", oceanMaterial);

            EditorGUILayout.Separator();

            GUILayout.Label("Normals", EditorStyles.boldLabel);
            GUILayout.Label("Displacement for fresnel, specular and reflection/refraction", EditorStyles.miniBoldLabel);

            float gerstnerNormalIntensity = WaterEditorUtility.GetMaterialFloat("_GerstnerIntensity", oceanMaterial);

            gerstnerNormalIntensity = EditorGUILayout.Slider("Per Vertex", gerstnerNormalIntensity, -2.5F, 2.5F);
            WaterEditorUtility.SetMaterialFloat("_GerstnerIntensity", gerstnerNormalIntensity, oceanMaterial);

            displacementParameter.x = EditorGUILayout.Slider("Per Pixel", displacementParameter.x, -4.0F, 4.0F);
            displacementParameter.y = EditorGUILayout.Slider("Distortion", displacementParameter.y, -0.5F, 0.5F);
            // fade.z = EditorGUILayout.Slider("Distance fade", fade.z, 0.0f, 0.5f);

            EditorGUILayout.Separator();

            GUILayout.Label("Fresnel", EditorStyles.boldLabel);
            GUILayout.Label("Defines reflection to refraction relation", EditorStyles.miniBoldLabel);

            if (!oceanMaterial.HasProperty("_Fresnel"))
            {
                if (oceanMaterial.HasProperty("_FresnelScale"))
                {
                    float fresnelScale = EditorGUILayout.Slider("Intensity", WaterEditorUtility.GetMaterialFloat("_FresnelScale", oceanMaterial), 0.1F, 4.0F);
                    WaterEditorUtility.SetMaterialFloat("_FresnelScale", fresnelScale, oceanMaterial);
                }
                displacementParameter.z = EditorGUILayout.Slider("Power", displacementParameter.z, 0.1F, 10.0F);
                displacementParameter.w = EditorGUILayout.Slider("Bias", displacementParameter.w, -3.0F, 3.0F);
            }
            else
            {
                Texture fresnelTex = (Texture)EditorGUILayout.ObjectField(
                    "Ramp",
                    (Texture)WaterEditorUtility.GetMaterialTexture("_Fresnel",
                                                                   oceanMaterial),
                    typeof(Texture),
                    false);
                WaterEditorUtility.SetMaterialTexture("_Fresnel", fresnelTex, oceanMaterial);
            }

            EditorGUILayout.Separator();

            WaterEditorUtility.SetMaterialVector("_DistortParams", displacementParameter, oceanMaterial);

            if (edgeBlend.boolValue)
            {
                GUILayout.Label("Fading", EditorStyles.boldLabel);

                fade.x = EditorGUILayout.Slider("Edge fade", fade.x, 0.001f, 3.0f);
                if (hasShore)
                {
                    fade.y = EditorGUILayout.Slider("Shore fade", fade.y, 0.001f, 3.0f);
                }
                fade.w = EditorGUILayout.Slider("Extinction fade", fade.w, 0.0f, 2.5f);

                WaterEditorUtility.SetMaterialVector("_InvFadeParemeter", fade, oceanMaterial);
            }
            EditorGUILayout.Separator();

            if (oceanMaterial.HasProperty("_Foam"))
            {
                GUILayout.Label("Foam", EditorStyles.boldLabel);

                Vector4 foam = WaterEditorUtility.GetMaterialVector("_Foam", oceanMaterial);

                foam.x = EditorGUILayout.Slider("Intensity", foam.x, 0.0F, 1.0F);
                foam.y = EditorGUILayout.Slider("Cutoff", foam.y, 0.0F, 1.0F);

                WaterEditorUtility.SetMaterialVector("_Foam", foam, oceanMaterial);
            }

            serObj.ApplyModifiedProperties();
        }
Exemplo n.º 28
0
    void DrawCameraGUI(tk2dCamera target, bool complete)
    {
        bool allowProjectionParameters = target.SettingsRoot == target;
        bool oldGuiEnabled = GUI.enabled;

        SerializedObject so = this.serializedObject;
        SerializedObject cam = new SerializedObject( target.camera );

        SerializedProperty m_ClearFlags = cam.FindProperty("m_ClearFlags");
        SerializedProperty m_BackGroundColor = cam.FindProperty("m_BackGroundColor");
        SerializedProperty m_CullingMask = cam.FindProperty("m_CullingMask");
        SerializedProperty m_TargetTexture = cam.FindProperty("m_TargetTexture");
        SerializedProperty m_Near = cam.FindProperty("near clip plane");
        SerializedProperty m_Far = cam.FindProperty("far clip plane");
        SerializedProperty m_Depth = cam.FindProperty("m_Depth");
        SerializedProperty m_RenderingPath = cam.FindProperty("m_RenderingPath");
        SerializedProperty m_HDR = cam.FindProperty("m_HDR");

        if (complete) {
            EditorGUILayout.PropertyField( m_ClearFlags );
            EditorGUILayout.PropertyField( m_BackGroundColor );
            EditorGUILayout.PropertyField( m_CullingMask );
            EditorGUILayout.Space();
        }

        tk2dCameraSettings cameraSettings = target.CameraSettings;
        tk2dCameraSettings inheritedSettings = target.SettingsRoot.CameraSettings;
        TransparencySortMode transparencySortMode = inheritedSettings.transparencySortMode;

        GUI.enabled &= allowProjectionParameters;
        inheritedSettings.projection = (tk2dCameraSettings.ProjectionType)EditorGUILayout.EnumPopup("Projection", inheritedSettings.projection);
        EditorGUI.indentLevel++;
        if (inheritedSettings.projection == tk2dCameraSettings.ProjectionType.Orthographic) {
            inheritedSettings.orthographicType = (tk2dCameraSettings.OrthographicType)EditorGUILayout.EnumPopup("Type", inheritedSettings.orthographicType);
            switch (inheritedSettings.orthographicType) {
                case tk2dCameraSettings.OrthographicType.OrthographicSize:
                    inheritedSettings.orthographicSize = Mathf.Max( 0.001f, EditorGUILayout.FloatField("Orthographic Size", inheritedSettings.orthographicSize) );
                    break;
                case tk2dCameraSettings.OrthographicType.PixelsPerMeter:
                    inheritedSettings.orthographicPixelsPerMeter = Mathf.Max( 0.001f, EditorGUILayout.FloatField("Pixels per Meter", inheritedSettings.orthographicPixelsPerMeter) );
                    break;
            }
            inheritedSettings.orthographicOrigin = (tk2dCameraSettings.OrthographicOrigin)EditorGUILayout.EnumPopup("Origin", inheritedSettings.orthographicOrigin);
        }
        else if (inheritedSettings.projection == tk2dCameraSettings.ProjectionType.Perspective) {
            inheritedSettings.fieldOfView = EditorGUILayout.Slider("Field of View", inheritedSettings.fieldOfView, 1, 179);
            transparencySortMode = (TransparencySortMode)EditorGUILayout.EnumPopup("Sort mode", transparencySortMode);
        }
        EditorGUI.indentLevel--;
        GUI.enabled = oldGuiEnabled;

        if (complete) {
            EditorGUILayout.Space();
            GUILayout.Label("Clipping Planes");
            GUILayout.BeginHorizontal();
            GUILayout.Space(14);
            GUILayout.Label("Near");
            if (m_Near != null) EditorGUILayout.PropertyField(m_Near, GUIContent.none, GUILayout.Width(60) );
            GUILayout.Label("Far");
            if (m_Far != null) EditorGUILayout.PropertyField(m_Far, GUIContent.none, GUILayout.Width(60) );
            GUILayout.EndHorizontal();
            cameraSettings.rect = EditorGUILayout.RectField("Normalized View Port Rect", cameraSettings.rect);

            EditorGUILayout.Space();
            if (m_Depth != null) EditorGUILayout.PropertyField(m_Depth);
            if (m_RenderingPath != null) EditorGUILayout.PropertyField(m_RenderingPath);
            if (m_TargetTexture != null) EditorGUILayout.PropertyField(m_TargetTexture);
            if (m_HDR != null) EditorGUILayout.PropertyField(m_HDR);
        }

        cam.ApplyModifiedProperties();
        so.ApplyModifiedProperties();

        if (transparencySortMode != inheritedSettings.transparencySortMode) {
            inheritedSettings.transparencySortMode = transparencySortMode;
            target.camera.transparencySortMode = transparencySortMode; // Change immediately in the editor
            EditorUtility.SetDirty(target);
            EditorUtility.SetDirty(target.camera);
        }
    }
Exemplo n.º 29
0
        public override void OnInspectorGUI()
        {
            GUIManager guiManager = target as GUIManager;

            if (guiManager == null)
            {
                return;
            }

            SerializedObject serializedObject = new SerializedObject(guiManager);

            EditorGUI.BeginChangeCheck();

#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            int guiTypeIndex = EditorGUILayout.Popup("GUI Type", guiManager.useuGUI ? 1 : 0, guiTypes);
            guiManager.useuGUI = guiTypeIndex == 1;
#endif
            DrawProperty(serializedObject, "clickDelay", "Click Delay");

            GUILayout.Label("Main Menu", "BoldLabel");
            DrawProperty(serializedObject, "mainMenuPanel", "Main Menu Panel");
            DrawProperty(serializedObject, "logoPanel", "Logo Panel");

            GUILayout.Label("In Game", "BoldLabel");
            DrawProperty(serializedObject, "inGameLeftPanel", "Left Panel");
            DrawProperty(serializedObject, "inGameTopPanel", "Top Panel");
            DrawProperty(serializedObject, "inGameRightPanel", "Right Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "inGameScoreText", "Score Text");
                DrawProperty(serializedObject, "inGameCoinsText", "Coins Text");
                DrawProperty(serializedObject, "inGameSecondaryCoinsText", "Secondary Coins Text");
                DrawProperty(serializedObject, "inGameActivePowerUpImage", "Active Power Up Image");
                DrawProperty(serializedObject, "inGamePowerUpSprites", "Power Up Sprites");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "inGameScore", "Score Label");
            DrawProperty(serializedObject, "inGameCoins", "Coins Label");
            DrawProperty(serializedObject, "inGameSecondaryCoins", "Secondary Coins Label");
            DrawProperty(serializedObject, "inGameActivePowerUp", "Active Power Up Sprite");
#endif
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif
            DrawProperty(serializedObject, "inGameActivePowerUpCutoffMaterial", "Active Power Up Cutoff Material");
            DrawProperty(serializedObject, "inGamePlayAnimation", "Play Animations");
            DrawProperty(serializedObject, "inGamePlayAnimationName", "Play Animation Name");

            GUILayout.Label("Pause", "BoldLabel");
            DrawProperty(serializedObject, "pausePanel", "Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "pauseScoreText", "Score Text");
                DrawProperty(serializedObject, "pauseCoinsText", "Coins Text");
                DrawProperty(serializedObject, "pauseSecondaryCoinsText", "Secondary Coins Text");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "pauseScore", "Score Label");
            DrawProperty(serializedObject, "pauseCoins", "Coins Label");
            DrawProperty(serializedObject, "pauseSecondaryCoins", "Secondary Coins Label");
#endif

#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif

            GUILayout.Label("Revive", "BoldLabel");
            DrawProperty(serializedObject, "revivePanel", "Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "reviveDescriptionText", "Description Text");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "reviveDescription", "Description Label");
#endif

#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif
            DrawProperty(serializedObject, "revivePlayAnimation", "Play Animation");
            DrawProperty(serializedObject, "revivePlayAnimationName", "Play Animation Name");
            DrawProperty(serializedObject, "reviveYesButton", "Yes Button");

            GUILayout.Label("End Game", "BoldLabel");
            DrawProperty(serializedObject, "endGamePanel", "Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "endGameScoreText", "Score Text");
                DrawProperty(serializedObject, "endGameCoinsText", "Coins Text");
                DrawProperty(serializedObject, "endGameMultiplierText", "Multiplier Text");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "endGameScore", "Score Label");
            DrawProperty(serializedObject, "endGameCoins", "Coins Label");
            DrawProperty(serializedObject, "endGameMultiplier", "Multiplier Label");
#endif
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif
            DrawProperty(serializedObject, "endGamePlayAnimation", "Play Animation");
            DrawProperty(serializedObject, "endGamePlayAnimationName", "Play Animation Name");

            GUILayout.Label("Store", "BoldLabel");
            DrawProperty(serializedObject, "storePanel", "Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "storePowerUpSelectionButtonText", "Power Up Selection Button Text");
                DrawProperty(serializedObject, "storeTitleText", "Score Text");
                DrawProperty(serializedObject, "storeDescriptionText", "Description Text");
                DrawProperty(serializedObject, "storeCoinsText", "Coins Text");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "storePowerUpSelectionButton", "Power Up Selection Button Label");
            DrawProperty(serializedObject, "storeTitle", "Score Label");
            DrawProperty(serializedObject, "storeDescription", "Description Label");
            DrawProperty(serializedObject, "storeCoins", "Coins Label");
#endif
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif
            DrawProperty(serializedObject, "storeBackToMainMenuButton", "Back To Main Menu GameObject");
            DrawProperty(serializedObject, "storeBackToEndGameButton", "Back To End Game GameObject");
            DrawProperty(serializedObject, "storeBuyButton", "Buy Button GameObject");
            DrawProperty(serializedObject, "storePowerUpPreviewTransform", "Power Up Preview Transform");
            DrawProperty(serializedObject, "storeCharacterPreviewTransform", "Character Preview Transform");

            GUILayout.Label("Stats", "BoldLabel");
            DrawProperty(serializedObject, "statsPanel", "Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "statsHighScoreText", "High Score Text");
                DrawProperty(serializedObject, "statsCoinsText", "Coins Text");
                DrawProperty(serializedObject, "statsSecondaryCoinsText", "Secondary Coins Text");
                DrawProperty(serializedObject, "statsPlayCountText", "Play Count Text");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "statsHighScore", "High Score Label");
            DrawProperty(serializedObject, "statsCoins", "Coins Label");
            DrawProperty(serializedObject, "statsSecondaryCoins", "Secondary Coins Label");
            DrawProperty(serializedObject, "statsPlayCount", "Play Count Label");
#endif
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif

            GUILayout.Label("Missions", "BoldLabel");
            DrawProperty(serializedObject, "missionsPanel", "Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "tutorialLabelText", "Tutorial Label Text");
                DrawProperty(serializedObject, "missionsActiveMission1Text", "Active Mission 1 Text");
                DrawProperty(serializedObject, "missionsActiveMission2Text", "Active Mission 2 Text");
                DrawProperty(serializedObject, "missionsActiveMission3Text", "Active Mission 3 Text");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "missionsScoreMultiplier", "Score Multiplier Label");
            DrawProperty(serializedObject, "missionsActiveMission1", "Active Mission 1 Label");
            DrawProperty(serializedObject, "missionsActiveMission2", "Active Mission 2 Label");
            DrawProperty(serializedObject, "missionsActiveMission3", "Active Mission 3 Label");
#endif

#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif
            DrawProperty(serializedObject, "missionsBackToMainMenuButton", "Back To Main Menu Button GameObject");
            DrawProperty(serializedObject, "missionsBackToEndGameButton", "Back To End Game Button GameObject");

            GUILayout.Label("In Game Missions", "BoldLabel");
            DrawProperty(serializedObject, "inGameMissionsPanel", "Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "inGameMissionsMissionCompleteText", "Mission Complete Text");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "inGameMissionsMissionComplete", "Mission Complete Label");
#endif

#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif

            GUILayout.Label("Tutorial", "BoldLabel");
            DrawProperty(serializedObject, "tutorialPanel", "Panel");
#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
            if (guiManager.useuGUI)
            {
                DrawProperty(serializedObject, "tutorialLabelText", "Tutorial Label Text");
            }
            else
            {
#endif
#if COMPILE_NGUI
            DrawProperty(serializedObject, "tutorialLabel", "Tutorial Label");
#endif

#if !(UNITY_4_3 || UNITY_4_4 || UNITY_4_5)
        }
#endif
            DrawProperty(serializedObject, "inGameMissionsPlayAnimation", "Play Animation");
            DrawProperty(serializedObject, "inGameMissionsPlayAnimationName", "Play Animation Name");

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Exemplo n.º 30
0
        public void OnGUI()
        {
            if (m_ItemDatabase == null)
            {
                EditorGUILayout.HelpBox("No ItemDatabase was found in the Resources folder!", MessageType.Error);

                if (GUILayout.Button("Refresh"))
                {
                    InitializeWindow();
                }

                if (m_ItemDatabase == null)
                {
                    return;
                }
            }

            GUIStyle richTextStyle = new GUIStyle()
            {
                richText = true, alignment = TextAnchor.UpperRight
            };

            // Display the database path.
            EditorGUILayout.LabelField(string.Format("Database path: '{0}'", AssetDatabase.GetAssetPath(m_ItemDatabase.targetObject)));

            // Display the shortcuts
            EditorGUI.LabelField(new Rect(position.width - 262f, 0f, 256f, 16f), "<b>Shift + D</b> to duplicate", richTextStyle);
            EditorGUI.LabelField(new Rect(position.width - 262f, 16f, 256f, 16f), "<b>Delete</b> to delete", richTextStyle);

            Vector2 buttonSize = new Vector2(192f, 32f);
            float   topPadding = 32f;

            // Draw the "Item Editor" button.
            Rect itemEditorButtonRect = new Rect(position.width * 0.25f - buttonSize.x / 2f, topPadding, buttonSize.x, buttonSize.y);

            if (m_SelectedTab == Tab.ItemEditor)
            {
                GUI.backgroundColor = Color.grey;
            }
            else
            {
                GUI.backgroundColor = Color.white;
            }

            if (GUI.Button(itemEditorButtonRect, "Item Editor"))
            {
                m_SelectedTab = Tab.ItemEditor;
            }

            // Draw the "Property Editor" button.
            Rect propertyEditorButtonRect = new Rect(position.width * 0.75f - buttonSize.x / 2f, topPadding, buttonSize.x, buttonSize.y);

            if (m_SelectedTab == Tab.PropertyEditor)
            {
                GUI.backgroundColor = Color.grey;
            }
            else
            {
                GUI.backgroundColor = Color.white;
            }

            if (GUI.Button(propertyEditorButtonRect, "Property Editor"))
            {
                m_SelectedTab = Tab.PropertyEditor;
            }

            // Reset the bg color.
            GUI.backgroundColor = Color.white;

            // Horizontal line.
            GUI.Box(new Rect(0f, topPadding + buttonSize.y * 1.25f, position.width, 1f), "");

            // Draw the item / recipe editors.
            m_ItemDatabase.Update();

            float innerWindowPadding = 8f;
            Rect  innerWindowRect    = new Rect(innerWindowPadding, topPadding + buttonSize.y * 1.25f + innerWindowPadding, position.width - innerWindowPadding * 2f, position.height - (topPadding + buttonSize.y * 1.25f + innerWindowPadding * 4.5f));

            // Inner window box.
            GUI.backgroundColor = Color.grey;
            GUI.Box(innerWindowRect, "");
            GUI.backgroundColor = Color.white;

            if (m_SelectedTab == Tab.ItemEditor)
            {
                DrawItemEditor(innerWindowRect);
            }
            else if (m_SelectedTab == Tab.PropertyEditor)
            {
                DrawPropertyEditor(innerWindowRect);
            }

            m_ItemDatabase.ApplyModifiedProperties();
        }
Exemplo n.º 31
0
 public void Apply()
 {
     serializedObject.ApplyModifiedProperties();
     serializedAdditionalDataObject.ApplyModifiedProperties();
 }