protected override void DrawModuleProperties()
 {
     exponent = EditorGUILayout.DoubleField("Exponent", exponent);
 }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            ChBody body = (ChBody)target;

            EditorGUILayout.HelpBox("Class for rigid bodies. A rigid body is an entity which can move in 3D space, and can be constrained to other rigid bodies using ChLink objects.", MessageType.Info);

            GUIContent type = new GUIContent("Collision Type", "Change what type of collision shape.");

            body.type = (ChBody.CollisionType)EditorGUILayout.EnumPopup(type, body.type);
            GUIContent bodyfixed = new GUIContent("Fixed", "Toggle whether the object is a static/fixed rigid body or dynamic.");

            body.bodyfixed = EditorGUILayout.Toggle(bodyfixed, body.bodyfixed);
            GUIContent collide = new GUIContent("Collide", "Toggle whether the rigid body can collide and interact with other collidable rigid body.");

            body.collide = EditorGUILayout.Toggle(collide, body.collide);

            GUIContent autoInertia = new GUIContent("Automatic Mass/Inertia", "Toggle whether the rigid body's mass and inertia is calculated automatically based on dimensions and custom density, or if you would like to set the mass and inertia manually.");

            body.automaticMass = EditorGUILayout.Toggle(autoInertia, body.automaticMass);

            if (body.automaticMass)
            {
                GUIContent density = new GUIContent("MDensity", "Set the rigid body density. Used when doing the 'recompute mass' operation.");
                body.density = EditorGUILayout.FloatField(density, body.density);
            }
            else
            {
                GUIContent mass = new GUIContent("Mass", "Mass of the rigid body. Must be positive. Try not to mix bodies with too high/too low values of mass, for numerical stability.");
                body.mass = EditorGUILayout.DoubleField(mass, body.mass);
                GUIContent inertXX = new GUIContent("Moments of Inertia", "Advanced, Set the diagonal part of the inertia tensor, The provided 3x1 vector should contain the moments of inertia, expressed in the local coordinate frame");
                body.inertiaMoments = EditorGUILayout.Vector3Field(inertXX, body.inertiaMoments);
                GUIContent inertXY = new GUIContent("Products of Inertia", "Advanced, Set the off-diagonal part of the inertia tensor (Ixy, Ixz, Iyz values). Warning about sign: in some books they write the inertia tensor as I=[Ixx, -Ixy, -Ixz; etc.] but here is I=[Ixx, Ixy, Ixz; ...]. The provided 3x1 vector should contain the products of inertia, expressed in the local coordinate frame:");
                body.inertiaProducts = EditorGUILayout.Vector3Field(inertXY, body.inertiaProducts);
            }

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            GUIContent linVel = new GUIContent("Linear Velocity", "Set the linear speed.  This is executed at startup once.");

            body.linearVelocity = EditorGUILayout.Vector3Field(linVel, body.linearVelocity);
            GUIContent angVel = new GUIContent("Angular Velocity", "Set the rotation speed from given angular speed.  This is executed at startup once.");

            body.angularVelocity = EditorGUILayout.Vector3Field(angVel, body.angularVelocity);

            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

            GUIContent matType = new GUIContent("Material Type", "Change the material physics type. NSC surface for use with non-smooth (complementarity) contact method.  SMC Material data for a surface for use with smooth (penalty) contact method. This data is used to define surface properties owned by ChBody rigid bodies and similar objects; it carries information that is used to make contacts.");

            body.materialType = (ChBody.MaterialType)EditorGUILayout.EnumPopup(matType, body.materialType);

            EditorGUI.indentLevel++;
            switch (body.materialType)
            {
            case ChBody.MaterialType.NSC:
                EditorGUILayout.PropertyField(friction, new GUIContent("Friction"), GUILayout.Height(20));
                GUIContent rolling = new GUIContent("Rolling Friction", "The rolling friction (rolling parameter, it has the dimension of a length). Rolling resistant torque is Tr <= (normal force) * (this parameter) Usually a very low value. Measuring unit: m  Default =0. Note! a non-zero value will make the simulation 2x slower! Also, the GPU solver currently does not support rolling friction. Default: 0.");
                EditorGUILayout.PropertyField(rolling_friction, new GUIContent(rolling), GUILayout.Height(20));
                GUIContent spinning = new GUIContent("Spinning Friction", "The spinning friction (it has the dimension of a length). Spinning resistant torque is Ts <= (normal force) * (this parameter) Usually a very low value.  Measuring unit: m Default =0. Note! a non-zero value will make the simulation 2x slower! Also, the GPU solver currently does not support spinning friction. Default: 0.");
                EditorGUILayout.PropertyField(spinning_friction, new GUIContent(spinning), GUILayout.Height(20));
                GUIContent rest = new GUIContent("Restitution", "The normal restitution coefficient, for collisions. Should be in 0..1 range. Default =0.");
                EditorGUILayout.PropertyField(restitution, new GUIContent(rest), GUILayout.Height(20));
                GUIContent coh = new GUIContent("Cohesion", "The cohesion max. force for normal pulling traction in contacts. Measuring unit: N Default =0.");
                EditorGUILayout.PropertyField(cohesion, new GUIContent(coh), GUILayout.Height(20));
                GUIContent dampf = new GUIContent("Dampingf", "The damping in contact, as a factor 'f': damping is a multiple of stiffness [K], that is: [R]=f*[K] Measuring unit: time, s. Default =0.");
                EditorGUILayout.PropertyField(dampingf, new GUIContent(dampf), GUILayout.Height(20));
                GUIContent comp = new GUIContent("Compliance", "Compliance of the contact, in normal direction. It is the inverse of the stiffness [K] , so for zero value one has a perfectly rigid contact. Measuring unit: m/N Default =0.");
                EditorGUILayout.PropertyField(compliance, new GUIContent(comp), GUILayout.Height(20));
                GUIContent compt = new GUIContent("ComplianceT", "Compliance of the contact, in normal direction. It is the inverse of the stiffness [K] , so for zero value one has a perfectly rigid contact. Measuring unit: m/N Default =0.");
                EditorGUILayout.PropertyField(complianceT, new GUIContent(compt), GUILayout.Height(20));
                GUIContent comproll = new GUIContent("Compliance Rolling", "Rolling compliance of the contact, if using a nonzero rolling friction. (If there is no rolling friction, this has no effect.) Measuring unit: rad/Nm Default =0.");
                EditorGUILayout.PropertyField(complianceRoll, new GUIContent(comproll), GUILayout.Height(20));
                GUIContent compspin = new GUIContent("Compliance Spinning", " Spinning compliance of the contact, if using a nonzero rolling friction. (If there is no spinning friction, this has no effect.) Measuring unit: rad/Nm Default =0.");
                EditorGUILayout.PropertyField(complianceSpin, new GUIContent(compspin), GUILayout.Height(20));

                serializedObject.ApplyModifiedProperties();

                //body.matsurface = body.gameObject.AddComponent<ChMaterialSurfaceNSC>() as ChMaterialSurfaceNSC;
                break;

            case ChBody.MaterialType.SMC:
                EditorGUILayout.PropertyField(friction, new GUIContent("Friction"), GUILayout.Height(20));
                GUIContent restsmc = new GUIContent("Restitution", "The normal restitution coefficient, for collisions. Should be in 0..1 range. Default =0.");
                EditorGUILayout.PropertyField(restitution, new GUIContent(restsmc), GUILayout.Height(20));
                GUIContent young = new GUIContent("Young Modulus", "Young's modulus, modulus of elasticity");
                EditorGUILayout.PropertyField(young_modulus, new GUIContent(young), GUILayout.Height(20));
                GUIContent poison = new GUIContent("Poisson Ratio", "Poisson's ratio is a measure of the Poisson effect, the phenomenon in which a material tends to expand in directions perpendicular to the direction of compression. Conversely, if the material is stretched rather than compressed, it usually tends to contract in the directions transverse to the direction of stretching.");
                EditorGUILayout.PropertyField(poisson_ratio, new GUIContent(poison), GUILayout.Height(20));
                // EditorGUILayout.PropertyField(static_friction, new GUIContent("Static Friction"), GUILayout.Height(20));
                EditorGUILayout.PropertyField(sliding_friction, new GUIContent("Sliding Friction"), GUILayout.Height(20));
                EditorGUILayout.PropertyField(constant_adhesion, new GUIContent("Constant Adhesion"), GUILayout.Height(20));
                EditorGUILayout.PropertyField(adhesionMultDMT, new GUIContent("AdhesionMultDMT"), GUILayout.Height(20));
                EditorGUILayout.PropertyField(kn, new GUIContent("Kn"), GUILayout.Height(20));
                EditorGUILayout.PropertyField(kt, new GUIContent("Kt"), GUILayout.Height(20));
                EditorGUILayout.PropertyField(gn, new GUIContent("Gn"), GUILayout.Height(20));
                EditorGUILayout.PropertyField(gt, new GUIContent("Gt"), GUILayout.Height(20));

                serializedObject.ApplyModifiedProperties();
                //matsurface = gameObject.AddComponent<ChMaterialSurfaceSMC>() as ChMaterialSurfaceSMC;
                break;
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(body);
            }
        }
        /// <summary>
        /// General window onGUI
        /// </summary>
        void OnGUI()
        {
            if (!_simControl || _simControlSerialized == null)
            {
                _simControl = FindSimulationControlGameObject();
                if (!_simControl)                  //check if creation process failed
                {
                    return;
                }
                InitializeProperties();
            }
            if (SimulationControl.instance == null)
            {
                SimulationControl.instance = _simControl;
            }
            _simControlSerialized.Update();
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUILayout.MinHeight(200), GUILayout.MaxHeight(1000), GUILayout.ExpandHeight(true));
            EditorGUILayout.LabelField("Tools:", EditorStyles.boldLabel);
            if (GUILayout.Button("Inverse velocity for all selected celestial bodies"))
            {
                InverseVelocityFor(Selection.gameObjects);                 //Undo functionality is supported
            }
            EditorGUILayout.LabelField("Global Parameters:", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(calcTypeProp, new GUIContent("N-Body algorithm(?)", "Euler - fastest performance, \nVerlet - fast and more stable, \nRungeKutta - more precise"));

            var gravConst = EditorGUILayout.DoubleField(new GUIContent("Gravitational Constant(?)", "Main constant. The real value 6.67384 * 10E-11 may not be very useful for gaming purposes"), _simControl.gravitationalConstant);

            if (gravConst != _simControl.gravitationalConstant)
            {
                Undo.RecordObject(_simControl, "Grav.Const change");
                _simControl.GravitationalConstant = gravConst;
            }
            gravConst = EditorGUILayout.DoubleField(new GUIContent("Grav.Const.Proportional(?)", "Change gravitational constant AND keep all orbits unaffected"), _simControl.gravitationalConstant);
            if (gravConst != _simControl.gravitationalConstant)
            {
                Undo.RecordObject(_simControl, "Grav.Const change");
                _simControl.GravitationalConstantProportional = gravConst;
            }
            EditorGUILayout.PropertyField(inflRangeProp, new GUIContent("Max influence range(?)", "global max range of n-body attraction"));
            EditorGUILayout.PropertyField(inflRangeMinProp, new GUIContent("Min influence range(?)", "global min range of n-body attraction"));
            EditorGUILayout.PropertyField(timeScaleProp, new GUIContent("Time Scale(?)", "Time multiplier. Note: high value will decrease n-body calculations precision"));
            EditorGUILayout.PropertyField(minMassProp, new GUIContent("Min attractor mass(?)", "Mass threshold for body to became attractor"));

            EditorGUILayout.PropertyField(eclipticNormalProp, new GUIContent("Ecliptic Normal Vector(?)", "Perpendicular to ecliptic plane"));
            EditorGUILayout.PropertyField(eclipticUpProp, new GUIContent("Ecliptic Up Vector(?)", "Up vector on ecliptic plane. used for rotation tool"));

            var keep2d = EditorGUILayout.Toggle(new GUIContent("Keep ALL bodies on ecliptic plane(?)", "2d mode. force all bodies to project positions and velocities onto ecliptic plane"), _simControl.keepBodiesOnEclipticPlane);

            if (keep2d != _simControl.keepBodiesOnEclipticPlane)
            {
                Undo.RecordObject(_simControl, "2d mode toggle");
                _simControl.keepBodiesOnEclipticPlane = keep2d;
                if (keep2d)
                {
                    _simControl.ProjectAllBodiesOnEcliptic();
                }
            }

            var scaledTime = EditorGUILayout.Toggle(new GUIContent("Affected by global timescale(?)", "toggle ignoring of Time.timeScale"), _simControl.affectedByGlobalTimescale);

            if (scaledTime != _simControl.affectedByGlobalTimescale)
            {
                Undo.RecordObject(_simControl, "affected by timescale toggle");
                _simControl.affectedByGlobalTimescale = scaledTime;
            }

            EditorGUILayout.LabelField("Set ecliptic normal along axis:", EditorStyles.boldLabel);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("X"))
            {
                SetEclipticNormal(new Vector3d(1, 0, 0), new Vector3d(0, 0, 1));
            }
            GUILayout.Space(6);
            if (GUILayout.Button("-X"))
            {
                SetEclipticNormal(new Vector3d(-1, 0, 0), new Vector3d(0, 0, -1));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Y"))
            {
                SetEclipticNormal(new Vector3d(0, 1, 0), new Vector3d(0, 0, 1));
            }
            GUILayout.Space(6);
            if (GUILayout.Button("-Y"))
            {
                SetEclipticNormal(new Vector3d(0, -1, 0), new Vector3d(0, 0, -1));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Z"))
            {
                SetEclipticNormal(new Vector3d(0, 0, 1), new Vector3d(1, 0, 0));
            }
            GUILayout.Space(6);
            if (GUILayout.Button("-Z"))
            {
                SetEclipticNormal(new Vector3d(0, 0, -1), new Vector3d(-1, 0, 0));
            }
            GUILayout.EndHorizontal();
            bool eclipticRotateTool = GUILayout.Toggle(_displayManager.IsEclipticRotating, "Rotate Ecliptic Plane", "Button");

            if (eclipticRotateTool != _displayManager.IsEclipticRotating)
            {
                _displayManager.IsEclipticRotating = eclipticRotateTool;
            }
            bool orbitRotateTool = GUILayout.Toggle(_displayManager.IsOrbitRotating, "Rotate Orbit Of Selected Obj.", "Button");

            if (orbitRotateTool != _displayManager.IsOrbitRotating)
            {
                _displayManager.IsOrbitRotating = orbitRotateTool;
            }
            EditorGUIUtility.labelWidth = 250f;
            EditorGUILayout.PropertyField(sceneViewDisplayParametersProp, true);
            GUILayout.Space(15);
            GUILayout.EndScrollView();
            if (GUI.changed)
            {
                _simControlSerialized.ApplyModifiedProperties();
                SceneView.RepaintAll();
            }
        }
Esempio n. 4
0
    public static object DrawIndividualVariable(ObjectPickerContext objectPickerContext, WrappedVariable variable, string fieldName, object fieldValue, OpenPickerCallback onObjectPicker, int index = 0)
    {
        object newValue;

        if (variable.DataType == DataType.Enum)
        {
            Type underlyingType = variable.MetaData.GetTypeFromMetaData();
            int  enumValueIndex = Array.IndexOf(variable.MetaData.EnumValues, fieldValue);
            enumValueIndex = EditorGUILayout.Popup(fieldName, enumValueIndex, variable.MetaData.EnumNames);

            newValue = variable.MetaData.EnumValues[enumValueIndex];
        }
        else if (variable.DataType == DataType.UnityObjectReference)
        {
            if (fieldValue is Guid)
            {
                EditorGUILayout.BeginHorizontal();
                Guid fieldValueGuid = (Guid)fieldValue;

                if (fieldValueGuid != Guid.Empty && variable.ValueDisplayNames.Length > index)
                {
                    EditorGUILayout.TextField(fieldName, variable.ValueDisplayNames[index]);
                }
                else
                {
                    EditorGUILayout.TextField(fieldName, "None (" + variable.MetaData.TypeFullName + ")");
                }

                if (objectPickerContext != null)
                {
                    if (GUILayout.Button("...", GUILayout.Width(30)))
                    {
                        onObjectPicker(objectPickerContext, variable);
                    }
                }

                bool guiEnabled = GUI.enabled;
                // Force GUI enabled on for this control
                GUI.enabled = (fieldValueGuid != Guid.Empty);
                if (GUILayout.Button("-->", GUILayout.Width(30)))
                {
                    APIManager       apiManager = BridgingContext.Instance.container.APIManager;
                    SidekickSettings settings   = BridgingContext.Instance.container.Settings;
                    apiManager.SendToPlayers(new GetObjectRequest((Guid)fieldValue, (InfoFlags)settings.GetGameObjectFlags));
                    Debug.Log(fieldValue);
                }

                GUI.enabled = guiEnabled;
                EditorGUILayout.EndHorizontal();

                newValue = fieldValue;
            }
            else
            {
                newValue = EditorGUILayout.ObjectField(fieldName, (UnityEngine.Object)fieldValue, variable.MetaData.GetTypeFromMetaData(), true);
            }
        }
        else if (variable.DataType == DataType.Integer)
        {
            newValue = EditorGUILayout.IntField(fieldName, (int)fieldValue);
        }
        else if (variable.DataType == DataType.Long)
        {
            newValue = EditorGUILayout.LongField(fieldName, (long)fieldValue);
        }
        else if (variable.DataType == DataType.String)
        {
            newValue = EditorGUILayout.TextField(fieldName, (string)fieldValue);
        }
        else if (variable.DataType == DataType.Char)
        {
            string newString = EditorGUILayout.TextField(fieldName, new string((char)fieldValue, 1));
            if (newString.Length == 1)
            {
                newValue = newString[0];
            }
            else
            {
                newValue = fieldValue;
            }
        }
        else if (variable.DataType == DataType.Float)
        {
            newValue = EditorGUILayout.FloatField(fieldName, (float)fieldValue);
        }
        else if (variable.DataType == DataType.Double)
        {
            newValue = EditorGUILayout.DoubleField(fieldName, (double)fieldValue);
        }
        else if (variable.DataType == DataType.Boolean)
        {
            newValue = EditorGUILayout.Toggle(fieldName, (bool)fieldValue);
        }
        else if (variable.DataType == DataType.Vector2)
        {
            newValue = EditorGUILayout.Vector2Field(fieldName, (Vector2)fieldValue);
        }
        else if (variable.DataType == DataType.Vector3)
        {
            newValue = EditorGUILayout.Vector3Field(fieldName, (Vector3)fieldValue);
        }
        else if (variable.DataType == DataType.Vector4)
        {
            newValue = EditorGUILayout.Vector4Field(fieldName, (Vector4)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.Vector2Int)
        {
            newValue = EditorGUILayout.Vector2IntField(fieldName, (Vector2Int)fieldValue);
        }
        else if (variable.DataType == DataType.Vector3Int)
        {
            newValue = EditorGUILayout.Vector3IntField(fieldName, (Vector3Int)fieldValue);
        }
#endif
        else if (variable.DataType == DataType.Quaternion)
        {
            //if(InspectorSidekick.Current.Settings.RotationsAsEuler)
            //{
            //  Quaternion quaternion = (Quaternion)fieldValue;
            //  Vector3 eulerAngles = quaternion.eulerAngles;
            //  eulerAngles = EditorGUILayout.Vector3Field(fieldName, eulerAngles);
            //  newValue = Quaternion.Euler(eulerAngles);
            //}
            //else
            {
                Quaternion quaternion = (Quaternion)fieldValue;
                Vector4    vector     = new Vector4(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
                vector   = EditorGUILayout.Vector4Field(fieldName, vector);
                newValue = new Quaternion(vector.x, vector.y, vector.z, vector.z);
            }
        }
        else if (variable.DataType == DataType.Bounds)
        {
            newValue = EditorGUILayout.BoundsField(fieldName, (Bounds)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.BoundsInt)
        {
            newValue = EditorGUILayout.BoundsIntField(fieldName, (BoundsInt)fieldValue);
        }
#endif
        else if (variable.DataType == DataType.Color)
        {
            newValue = EditorGUILayout.ColorField(fieldName, (Color)fieldValue);
        }
        else if (variable.DataType == DataType.Color32)
        {
            newValue = (Color32)EditorGUILayout.ColorField(fieldName, (Color32)fieldValue);
        }
        else if (variable.DataType == DataType.Gradient)
        {
            newValue = InternalEditorGUILayout.GradientField(new GUIContent(fieldName), (Gradient)fieldValue);
        }
        else if (variable.DataType == DataType.AnimationCurve)
        {
            newValue = EditorGUILayout.CurveField(fieldName, (AnimationCurve)fieldValue);
        }
        else if (variable.DataType == DataType.Rect)
        {
            newValue = EditorGUILayout.RectField(fieldName, (Rect)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.RectInt)
        {
            newValue = EditorGUILayout.RectIntField(fieldName, (RectInt)fieldValue);
        }
#endif
        else
        {
            GUILayout.Label(fieldName);
            newValue = fieldValue;
        }

        return(newValue);
    }
        public override void OnInspectorGUI()
        {
            Initialize();

            var mapRenderer = (MapRenderer)target;

            serializedObject.UpdateIfRequiredOrScript();

            RenderBanner();

            // Setup and key.
            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUILayout.LabelField("API Settings", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            _bingMapsKeyProperty.stringValue = EditorGUILayout.PasswordField("Bing Maps Key", _bingMapsKeyProperty.stringValue);
            if (string.IsNullOrWhiteSpace(_bingMapsKeyProperty.stringValue))
            {
                Help(
                    "Provide a Bing Maps developer key to enable the map.",
                    "Sign up for a key at the Bing Maps Dev Center.",
                    "https://www.bingmapsportal.com/");
            }

            _showMapDataInEditorProperty.boolValue =
                EditorGUILayout.Toggle(
                    new GUIContent(
                        "Show Map Data in Editor",
                        "Map data usage in the editor will apply the specified Bing Maps key."),
                    _showMapDataInEditorProperty.boolValue);
            EditorGUILayout.EndVertical();

            // Location Section
            EditorGUILayout.BeginVertical(_boxStyle);
            _showMapLocationOptions = EditorGUILayout.Foldout(_showMapLocationOptions, "Location", true, _foldoutTitleStyle);
            if (_showMapLocationOptions)
            {
                var latitudeProperty = _centerProperty.FindPropertyRelative("Latitude");
                latitudeProperty.doubleValue = EditorGUILayout.DoubleField("Latitude", latitudeProperty.doubleValue);
                var longitudeProperty = _centerProperty.FindPropertyRelative("Longitude");
                longitudeProperty.doubleValue = EditorGUILayout.DoubleField("Longitude", longitudeProperty.doubleValue);

                EditorGUILayout.Slider(_zoomLevelProperty, MapConstants.MinimumZoomLevel, MapConstants.MaximumZoomLevel);
                // Get the zoomlevel values
                var minZoomLevel = _minZoomLevelProperty.floatValue;
                var maxZoomLevel = _maxZoomLevelProperty.floatValue;

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Zoom Level Range");
                EditorGUI.indentLevel--;
                minZoomLevel = EditorGUILayout.FloatField((float)Math.Round(minZoomLevel, 2), _minMaxLabelsLayoutOptions);
                EditorGUILayout.MinMaxSlider(ref minZoomLevel, ref maxZoomLevel, MapConstants.MinimumZoomLevel, MapConstants.MaximumZoomLevel);
                maxZoomLevel = EditorGUILayout.FloatField((float)Math.Round(maxZoomLevel, 2), _minMaxLabelsLayoutOptions);
                EditorGUI.indentLevel++;
                EditorGUILayout.EndHorizontal();

                // Update it back
                _minZoomLevelProperty.floatValue = minZoomLevel;
                _maxZoomLevelProperty.floatValue = maxZoomLevel;
                GUILayout.Space(4);
            }
            EditorGUILayout.EndVertical();

            // Map Layout Section
            EditorGUILayout.BeginVertical(_boxStyle);
            _showMapSizingOptions = EditorGUILayout.Foldout(_showMapSizingOptions, "Map Layout", true, _foldoutTitleStyle);
            if (_showMapSizingOptions)
            {
                // Map Shape Controls
                GUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Map Shape");
                _mapShapeProperty.enumValueIndex = GUILayout.Toolbar(_mapShapeProperty.enumValueIndex, _shapeOptions);
                GUILayout.EndHorizontal();

                GUILayout.Space(6f);

                if (_mapShapeProperty.enumValueIndex == (int)MapShape.Block)
                {
                    EditorGUILayout.PropertyField(_localMapDimensionProperty);
                    EditorGUILayout.LabelField(" ", "Scaled Map Dimension: " + ((MapRenderer)target).MapDimension.ToString());
                    EditorGUILayout.PropertyField(_localMapHeightProperty);
                    EditorGUILayout.LabelField(" ", "Scaled Map Height: " + ((MapRenderer)target).MapHeight.ToString());
                }
                else if (_mapShapeProperty.enumValueIndex == (int)MapShape.Cylinder)
                {
                    EditorGUILayout.PropertyField(_localMapRadiusProperty);
                    EditorGUILayout.LabelField(" ", "Scaled Map Radius: " + (((MapRenderer)target).MapDimension.x / 2.0f).ToString());
                    EditorGUILayout.PropertyField(_localMapHeightProperty);
                    EditorGUILayout.LabelField(" ", "Scaled Map Height: " + ((MapRenderer)target).MapHeight.ToString());
                }
            }
            EditorGUILayout.EndVertical();

            // Render Settings Section
            EditorGUILayout.BeginVertical(_boxStyle);
            _terrainOptions = EditorGUILayout.Foldout(_terrainOptions, "Render Settings", true, _foldoutTitleStyle);
            if (_terrainOptions)
            {
                // Map Terrain Type Controls
                GUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Map Terrain Type");
                _mapTerrainType.enumValueIndex = GUILayout.Toolbar(_mapTerrainType.enumValueIndex, _layerOptions);
                GUILayout.EndHorizontal();

                EditorGUILayout.PropertyField(_castShadowsProperty, new GUIContent("Cast Shadows"));
                EditorGUILayout.PropertyField(_receiveShadowsProperty, new GUIContent("Receive Shadows"));
                EditorGUILayout.PropertyField(_enableMrtkMaterialIntegrationProperty, new GUIContent("Enable MRTK Integration"));
                EditorGUILayout.PropertyField(_useCustomTerrainMaterialProperty, new GUIContent("Use Custom Terrain Material"));
                if (_useCustomTerrainMaterialProperty.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(_customTerrainMaterialProperty, new GUIContent("Terrain Material"));
                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.PropertyField(_mapEdgeColorProperty, new GUIContent("Color"));
                _mapEdgeColorFadeDistanceProperty.floatValue =
                    EditorGUILayout.Slider(new GUIContent("Edge Fade"), _mapEdgeColorFadeDistanceProperty.floatValue, 0, 1);
                EditorGUILayout.PropertyField(_isClippingVolumeWallEnabledProperty, new GUIContent("Render Clipping Volume Wall"));
                if (_isClippingVolumeWallEnabledProperty.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(
                        _useCustomClippingVolumeMaterialProperty,
                        new GUIContent("Use Custom Clipping Volume Material"));
                    if (_useCustomClippingVolumeMaterialProperty.boolValue)
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(_customClippingVolumeMaterialProperty, new GUIContent("Clipping Volume Material"));
                        EditorGUI.indentLevel--;
                    }

                    // Texture Camera Resolution
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Clipping Edge Resolution");
                    _clippingVolumeDistanceTextureResolution.enumValueIndex = GUILayout.Toolbar(
                        _clippingVolumeDistanceTextureResolution.enumValueIndex, _clippingVolumeDistanceTextureResolutionOptions);
                    GUILayout.EndHorizontal();

                    EditorGUI.indentLevel--;
                }
            }
            GUILayout.Space(6f);
            EditorGUILayout.EndVertical();

            // Quality options.
            EditorGUILayout.BeginVertical(_boxStyle);
            _showQualityOptions = EditorGUILayout.Foldout(_showQualityOptions, "Quality", true, _foldoutTitleStyle);
            if (_showQualityOptions)
            {
                EditorGUI.BeginDisabledGroup(Application.isPlaying);
                _maxCacheSizeInBytesProperty.longValue =
                    1024 *
                    1024 *
                    EditorGUILayout.LongField(
                        new GUIContent("Max Cache Size (MB)"),
                        _maxCacheSizeInBytesProperty.longValue / 1024 / 1024);
                EditorGUI.EndDisabledGroup();

                var position = EditorGUILayout.GetControlRect(false, 2 * EditorGUIUtility.singleLineHeight);
                position.height = EditorGUIUtility.singleLineHeight;

                position = EditorGUI.PrefixLabel(position, new GUIContent("Detail Offset"));
                EditorGUI.indentLevel--;

                _detailOffsetProperty.floatValue = EditorGUI.Slider(position, _detailOffsetProperty.floatValue, -1f, 1f);
                float labelWidth = position.width;

                // Render the sub-text labels.
                {
                    position.y     += EditorGUIUtility.singleLineHeight;
                    position.width -= EditorGUIUtility.fieldWidth;

                    var color = GUI.color;
                    GUI.color = color * new Color(1f, 1f, 1f, 0.5f);

                    GUIStyle style =
                        new GUIStyle(GUI.skin.label)
                    {
                        alignment = TextAnchor.UpperLeft
                    };

                    EditorGUI.LabelField(position, "Low", style);

                    style.alignment = TextAnchor.UpperCenter;
                    EditorGUI.LabelField(position, "Default", style);

                    style.alignment = TextAnchor.UpperRight;
                    EditorGUI.LabelField(position, "High", style);

                    GUI.color = color;
                }

                EditorGUI.indentLevel++;
            }
            EditorGUILayout.EndVertical();

            // Texture Tile Providers
            EditorGUILayout.BeginVertical(_boxStyle);
            _showTileLayers = EditorGUILayout.Foldout(_showTileLayers, "Tile Layers", true, _foldoutTitleStyle);
            if (_showTileLayers)
            {
                EditorGUILayout.PropertyField(_textureTileLayersProperty, true);
                EditorGUILayout.PropertyField(_hideTileLayerComponentsProperty);
                GUILayout.Space(12f);
            }
            EditorGUILayout.EndVertical();


            GUILayout.Space(4);
            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 6
0
        void DrawGraphRecusively(NodeBase node, bool isEditable = false)
        {
            EditorGUILayout.BeginVertical();
            {
                Rect parentRect;
                var  children = node.GetAllChildren();
                var  fields   = node.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                Dictionary <string, object> changedValues = new Dictionary <string, object>();


                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                {
                    Color defaultColor = GUI.color;
                    GUILayout.BeginVertical(node.GetType().Name.Substring(4, node.GetType().Name.Length - 4), "window", GUILayout.Width(200));

                    switch (node.State)
                    {
                    case NodeState.Running:
                        GUI.color = Color.yellow;
                        break;

                    case NodeState.Success:
                        GUI.color = Color.green;
                        break;

                    case NodeState.Fail:
                        GUI.color = Color.red;
                        break;
                    }

                    if (node.parentNode != null && isEditable == true)
                    {
                        var parentNode = node.parentNode;
                        var nodeIndex  = parentNode.ChildIndexOf(node);
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button("◀") &&
                            nodeIndex > 0)
                        {
                            parentNode.RemoveChild(node);
                            parentNode.AddChild(node, nodeIndex - 1);
                        }
                        if (GUILayout.Button("▲") &&
                            parentNode.parentNode != null)
                        {
                            parentNode.RemoveChild(node);
                            parentNode.parentNode.AddChild(node);
                        }
                        if (GUILayout.Button("▼") &&
                            nodeIndex > 0 && parentNode.GetChildrenCount() >= 2)
                        {
                            parentNode.RemoveChild(node);
                            parentNode.GetChild(nodeIndex - 1).AddChild(node);
                        }
                        if (GUILayout.Button("▶") &&
                            nodeIndex < parentNode.GetChildrenCount() - 1)
                        {
                            parentNode.RemoveChild(node);
                            parentNode.AddChild(node, nodeIndex + 1);
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        GUILayout.Box("", GUILayout.ExpandWidth(true));
                    }

                    if (isEditable == true)
                    {
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button("Copy"))
                        {
                            m_CopiedAttributes.Clear();
                            for (int i = 0; i < fields.Length; i++)
                            {
                                object[] attributes = fields[i].GetCustomAttributes(typeof(NodeAttribute), true);
                                if (attributes == null || attributes.Length == 0)
                                {
                                    continue;
                                }

                                NodeAttribute nodeAttr = attributes[0] as NodeAttribute;
                                if (nodeAttr == null)
                                {
                                    continue;
                                }
                                if (nodeAttr.Option != NodeAttributeOptionType.Required)
                                {
                                    continue;
                                }

                                m_CopiedAttributes.Add(nodeAttr.Name, fields[i].GetValue(node));
                            }
                        }
                        if (GUILayout.Button("Paste"))
                        {
                            for (int i = 0; i < fields.Length; i++)
                            {
                                object[] attributes = fields[i].GetCustomAttributes(typeof(NodeAttribute), true);
                                if (attributes == null || attributes.Length == 0)
                                {
                                    continue;
                                }

                                NodeAttribute nodeAttr = attributes[0] as NodeAttribute;
                                if (nodeAttr == null)
                                {
                                    continue;
                                }
                                if (m_CopiedAttributes.ContainsKey(nodeAttr.Name) == false)
                                {
                                    continue;
                                }

                                fields[i].SetValue(node, m_CopiedAttributes[nodeAttr.Name]);
                            }
                        }
                        if (GUILayout.Button("Delete") && node.parentNode != null)
                        {
                            var parentNode = node.parentNode;
                            parentNode.RemoveChild(node);
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        GUILayout.Box("", GUILayout.ExpandWidth(true));
                    }

                    if (node is NodeRoot)
                    {
                        GUILayout.Label("", GUILayout.Width(GRAPH_WINDOW_NAME_WIDTH + GRAPH_WINDOW_VALUE_WIDTH));
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label("Name", GUILayout.Width(GRAPH_WINDOW_NAME_WIDTH));
                        var changedName = EditorGUILayout.TextField(node.Name, GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        if (changedName != node.Name)
                        {
                            changedValues.Add("Name", changedName);
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("State", GUILayout.Width(GRAPH_WINDOW_NAME_WIDTH));
                    GUILayout.Label(node.State.ToString(), GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                    EditorGUILayout.EndHorizontal();
                    GUILayout.Space(10);

                    for (int i = 0; i < fields.Length; i++)
                    {
                        object[] attributes = fields[i].GetCustomAttributes(typeof(NodeAttribute), true);
                        if (attributes == null || attributes.Length == 0)
                        {
                            continue;
                        }

                        NodeAttribute nodeAttr = attributes[0] as NodeAttribute;
                        if (nodeAttr == null)
                        {
                            continue;
                        }
                        if (nodeAttr.Name == "Name")
                        {
                            continue;
                        }
                        // if (nodeAttr.Option != NodeAttributeOptionType.Required) continue;

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label(nodeAttr.Name, GUILayout.Width(GRAPH_WINDOW_NAME_WIDTH));
                        object changedValue = null;
                        if (fields[i].FieldType == typeof(string))
                        {
                            changedValue = EditorGUILayout.TextField((string)fields[i].GetValue(node), GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        }
                        else if (fields[i].FieldType == typeof(int))
                        {
                            changedValue = EditorGUILayout.IntField((int)fields[i].GetValue(node), GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        }
                        else if (fields[i].FieldType == typeof(long))
                        {
                            changedValue = EditorGUILayout.LongField((long)fields[i].GetValue(node), GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        }
                        else if (fields[i].FieldType == typeof(float))
                        {
                            changedValue = EditorGUILayout.FloatField((float)fields[i].GetValue(node), GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        }
                        else if (fields[i].FieldType == typeof(double))
                        {
                            changedValue = EditorGUILayout.DoubleField((double)fields[i].GetValue(node), GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        }
                        else if (fields[i].FieldType == typeof(bool))
                        {
                            changedValue = EditorGUILayout.Toggle((bool)fields[i].GetValue(node), GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        }
                        else if (fields[i].FieldType.IsEnum)
                        {
                            changedValue = EditorGUILayout.EnumPopup((Enum)fields[i].GetValue(node), GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        }
                        else
                        {
                            GUILayout.Label(fields[i].FieldType.Name, GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        }
                        EditorGUILayout.EndHorizontal();

                        if (changedValue != null)
                        {
                            if (changedValue is IComparable)
                            {
                                if (((IComparable)fields[i].GetValue(node)).CompareTo(changedValue) != 0)
                                {
                                    changedValues.Add(nodeAttr.Name, changedValue);
                                }
                            }
                            else
                            {
                                if (fields[i].GetValue(node) != changedValue)
                                {
                                    changedValues.Add(nodeAttr.Name, changedValue);
                                }
                            }
                        }
                    }


                    if (isEditable == true)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        var addSelectedIndex = EditorGUILayout.Popup(0, ADDABLE_NODE_TYPES, GUILayout.Width(GRAPH_WINDOW_VALUE_WIDTH));
                        if (addSelectedIndex > 0)
                        {
                            Type nodeType = Util.GetNodeType(ADDABLE_NODE_TYPES[addSelectedIndex]);
                            if (nodeType != null)
                            {
                                NodeBase newNode = Activator.CreateInstance(nodeType) as NodeBase;
                                node.AddChild(newNode);
                            }
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        GUILayout.Box("", GUILayout.ExpandWidth(true));
                    }
                    GUILayout.EndVertical();
                    parentRect = GUILayoutUtility.GetLastRect();
                    GUI.color  = defaultColor;
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();


                if (isEditable == true &&
                    changedValues.Count > 0)
                {
                    for (int i = 0; i < fields.Length; i++)
                    {
                        object[] attributes = fields[i].GetCustomAttributes(typeof(NodeAttribute), true);
                        if (attributes == null || attributes.Length == 0)
                        {
                            continue;
                        }

                        NodeAttribute nodeAttr = attributes[0] as NodeAttribute;
                        if (nodeAttr == null)
                        {
                            continue;
                        }
                        if (changedValues.ContainsKey(nodeAttr.Name) == false)
                        {
                            continue;
                        }

                        fields[i].SetValue(node, changedValues[nodeAttr.Name]);
                    }
                }

                if (children.Length > 0)
                {
                    GUILayout.Space(GRAPH_SPACE_Y - 10);
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(10));

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Box("", GUILayout.Width(10), GUILayout.ExpandHeight(true));
                    GUILayout.Space(GRAPH_SPACE_X - 10);
                    for (int i = 0; i < children.Length; i++)
                    {
                        if (i > 0)
                        {
                            GUILayout.Space(GRAPH_SPACE_X);
                        }
                        DrawGraphRecusively(children[i], isEditable);
                        Rect    childRect = GUILayoutUtility.GetLastRect();
                        Vector3 startPos  = new Vector3(
                            parentRect.center.x,
                            parentRect.center.y + parentRect.height * 0.5f,
                            0);
                        Vector3 endPos = new Vector3(
                            childRect.center.x,
                            childRect.center.y - childRect.height * 0.5f,
                            0);
                        if (EditorGUIUtility.isProSkin == false) //outline
                        {
                            Handles.DrawBezier(startPos, endPos,
                                               new Vector3(startPos.x, endPos.y, 0),
                                               new Vector3(endPos.x, startPos.y, 0),
                                               Color.black,
                                               null, 4f);
                        }
                        Handles.DrawBezier(startPos, endPos,
                                           new Vector3(startPos.x, endPos.y, 0),
                                           new Vector3(endPos.x, startPos.y, 0),
                                           children[i].State == NodeState.Running ? Color.yellow : Color.white,
                                           null, 2f);
                    }
                    GUILayout.Space(GRAPH_SPACE_X - 10);
                    GUILayout.Box("", GUILayout.Width(10), GUILayout.ExpandHeight(true));
                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndVertical();
        }
Esempio n. 7
0
            public void ShowField()
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                switch (parameterType)
                {
                case ParameterType.Bool:
                    VariableField <BoolValue>(v =>
                    {
                        v_bool = v.value;
                        EditorGUILayout.HelpBox(v_bool + " << 変数の値(" + variable.valueName + ")",
                                                MessageType.Info);
                    }, () => v_bool = EditorGUILayout.Toggle(parameterName, v_bool));
                    break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                EditorGUILayout.EndVertical();
            }
        static void OnGUIContents(GeneratorCylinder generator, bool isSceneGUI)
        {
            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
            {
                if (isSceneGUI)
                {
                    CylinderSettingsGUI(generator, isSceneGUI);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
            {
                var distanceUnit = RealtimeCSG.CSGSettings.DistanceUnit;
                var nextUnit     = Units.CycleToNextUnit(distanceUnit);
                var unitText     = Units.GetUnitGUIContent(distanceUnit);

                GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                {
                    GUILayout.Label(HeightContent, width65);

                    if (isSceneGUI)
                    {
                        TooltipUtility.SetToolTip(HeightTooltip);
                    }

                    var height = generator.HaveHeight ? generator.Height : GeometryUtility.CleanLength(generator.DefaultHeight);
                    EditorGUI.BeginChangeCheck();
                    {
                        if (!isSceneGUI)
                        {
                            height = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, height)));
                        }
                        else
                        {
                            height = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, height), width65));
                        }
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        if (generator.HaveHeight)
                        {
                            generator.Height = height;
                        }
                        else
                        {
                            generator.DefaultHeight = height;
                        }
                    }

                    if (GUILayout.Button(unitText, EditorStyles.miniLabel, width25))
                    {
                        distanceUnit = nextUnit;
                        RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                        RealtimeCSG.CSGSettings.UpdateSnapSettings();
                        RealtimeCSG.CSGSettings.Save();
                        CSG_EditorGUIUtility.RepaintAll();
                    }
                }
                GUILayout.EndHorizontal();

                TooltipUtility.SetToolTip(HeightTooltip);

                GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                {
                    EditorGUI.BeginDisabledGroup(!generator.CanCommit);
                    {
                        GUILayout.Label(RadiusContent, width65);

                        if (isSceneGUI)
                        {
                            TooltipUtility.SetToolTip(RadiusTooltip);
                        }

                        var radius = generator.RadiusA;
                        EditorGUI.BeginChangeCheck();
                        {
                            if (!isSceneGUI)
                            {
                                radius = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, radius)));
                            }
                            else
                            {
                                radius = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, radius), width65));
                            }
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            generator.RadiusA = radius;
                        }

                        if (GUILayout.Button(unitText, EditorStyles.miniLabel, width25))
                        {
                            distanceUnit = nextUnit;
                            RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                            RealtimeCSG.CSGSettings.UpdateSnapSettings();
                            RealtimeCSG.CSGSettings.Save();
                            CSG_EditorGUIUtility.RepaintAll();
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();

                if (!isSceneGUI)
                {
                    TooltipUtility.SetToolTip(RadiusTooltip);
                }
            }

            GUILayout.EndVertical();
            {
                generator.CircleSides = IntSettingsControl
                                        (
                    generator.CircleSides,
                    3,
                    RealtimeCSG.CSGSettings.MaxCircleSides,
                    SidesContent,
                    isSceneGUI
                                        );

                TooltipUtility.SetToolTip(SidesTooltip);
            }
            generator.CircleOffset = FloatSettingsControl
                                     (
                generator.CircleOffset,
                0,
                360,
                OffsetContent,
                isSceneGUI
                                     );

            TooltipUtility.SetToolTip(OffsetTooltip);


            if (!isSceneGUI)
            {
                GUILayout.Space(5);

                CylinderSettingsGUI(generator, isSceneGUI);
            }
        }
Esempio n. 9
0
        private void InspectObjective(BioObjective objective)
        {
            Undo.RecordObject(objective, objective.name);

            SetGUIColor(Color13);
            using (new EditorGUILayout.VerticalScope("Box")) {
                SetGUIColor(Color5);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUILayout.HelpBox("                    Objective (" + objective.GetObjectiveType().ToString() + ")                    ", MessageType.None);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                SetGUIColor(Color1);
                objective.enabled = EditorGUILayout.Toggle("Enabled", objective.enabled);

                SetGUIColor(Color1);
                objective.Weight = EditorGUILayout.DoubleField("Weight", objective.Weight);

                switch (objective.GetObjectiveType())
                {
                case ObjectiveType.Position:
                    InspectPosition((Position)objective);
                    break;

                case ObjectiveType.Orientation:
                    InspectOrientation((Orientation)objective);
                    break;

                case ObjectiveType.LookAt:
                    InspectLookAt((LookAt)objective);
                    break;

                case ObjectiveType.Distance:
                    InspectDistance((Distance)objective);
                    break;

                case ObjectiveType.JointValue:
                    InspectJointValue((JointValue)objective);
                    break;

                case ObjectiveType.Displacement:
                    InspectDisplacement((Displacement)objective);
                    break;

                case ObjectiveType.Projection:
                    InspectProjection((Projection)objective);
                    break;
                }

                GUI.skin.button.alignment = TextAnchor.MiddleCenter;
                SetGUIColor(Color7);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Remove", GUILayout.Width(100f)))
                {
                    objective.Remove();
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            if (objective != null)
            {
                EditorUtility.SetDirty(objective);
            }
        }
Esempio n. 10
0
    public static object DrawIndividualVariable(ComponentDescription componentDescription, WrappedVariable variable, string fieldName, Type fieldType, object fieldValue, Action <Guid, WrappedVariable> onObjectPicker)
    {
        object newValue;

        if (variable.DataType == DataType.Enum)
        {
            newValue = EditorGUILayout.IntPopup(fieldName, (int)fieldValue, variable.MetaData.EnumNames, variable.MetaData.EnumValues);
        }
        else if (variable.DataType == DataType.UnityObjectReference)
        {
            if (fieldValue is Guid)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(fieldName);
                if ((Guid)fieldValue != Guid.Empty)
                {
                    EditorGUILayout.TextField(variable.MetaData.ValueDisplayName);
                }
                else
                {
                    EditorGUILayout.TextField("None (" + variable.MetaData.TypeFullName + ")");
                }
                if (componentDescription != null)
                {
                    if (GUILayout.Button("...", GUILayout.Width(30)))
                    {
                        onObjectPicker(componentDescription.Guid, variable);
                    }
                }
                EditorGUILayout.EndHorizontal();

                newValue = fieldValue;
            }
            else if (typeof(UnityEngine.Object).IsAssignableFrom(fieldType))
            {
                newValue = EditorGUILayout.ObjectField(fieldName, (UnityEngine.Object)fieldValue, variable.MetaData.GetTypeFromMetaData(), true);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
        else if (fieldType == typeof(int) ||
                 (fieldType.IsSubclassOf(typeof(Enum)) && OldInspectorSidekick.Current.Settings.TreatEnumsAsInts))
        {
            newValue = EditorGUILayout.IntField(fieldName, (int)fieldValue);
        }
        else if (fieldType == typeof(long))
        {
            newValue = EditorGUILayout.LongField(fieldName, (long)fieldValue);
        }
        else if (fieldType == typeof(string))
        {
            newValue = EditorGUILayout.TextField(fieldName, (string)fieldValue);
        }
        else if (fieldType == typeof(char))
        {
            string newString = EditorGUILayout.TextField(fieldName, new string((char)fieldValue, 1));
            if (newString.Length == 1)
            {
                newValue = newString[0];
            }
            else
            {
                newValue = fieldValue;
            }
        }
        else if (fieldType == typeof(float))
        {
            newValue = EditorGUILayout.FloatField(fieldName, (float)fieldValue);
        }
        else if (fieldType == typeof(double))
        {
            newValue = EditorGUILayout.DoubleField(fieldName, (double)fieldValue);
        }
        else if (fieldType == typeof(bool))
        {
            newValue = EditorGUILayout.Toggle(fieldName, (bool)fieldValue);
        }
        else if (fieldType == typeof(Vector2))
        {
            newValue = EditorGUILayout.Vector2Field(fieldName, (Vector2)fieldValue);
        }
        else if (fieldType == typeof(Vector3))
        {
            newValue = EditorGUILayout.Vector3Field(fieldName, (Vector3)fieldValue);
        }
        else if (fieldType == typeof(Vector4))
        {
            newValue = EditorGUILayout.Vector4Field(fieldName, (Vector4)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (fieldType == typeof(Vector2Int))
        {
            newValue = EditorGUILayout.Vector2IntField(fieldName, (Vector2Int)fieldValue);
        }
        else if (fieldType == typeof(Vector3Int))
        {
            newValue = EditorGUILayout.Vector3IntField(fieldName, (Vector3Int)fieldValue);
        }
#endif
        else if (fieldType == typeof(Quaternion))
        {
            //if(InspectorSidekick.Current.Settings.RotationsAsEuler)
            //{
            //  Quaternion quaternion = (Quaternion)fieldValue;
            //  Vector3 eulerAngles = quaternion.eulerAngles;
            //  eulerAngles = EditorGUILayout.Vector3Field(fieldName, eulerAngles);
            //  newValue = Quaternion.Euler(eulerAngles);
            //}
            //else
            {
                Quaternion quaternion = (Quaternion)fieldValue;
                Vector4    vector     = new Vector4(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
                vector   = EditorGUILayout.Vector4Field(fieldName, vector);
                newValue = new Quaternion(vector.x, vector.y, vector.z, vector.z);
            }
        }
        else if (fieldType == typeof(Bounds))
        {
            newValue = EditorGUILayout.BoundsField(fieldName, (Bounds)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (fieldType == typeof(BoundsInt))
        {
            newValue = EditorGUILayout.BoundsIntField(fieldName, (BoundsInt)fieldValue);
        }
#endif
        else if (fieldType == typeof(Color))
        {
            newValue = EditorGUILayout.ColorField(fieldName, (Color)fieldValue);
        }
        else if (fieldType == typeof(Color32))
        {
            newValue = (Color32)EditorGUILayout.ColorField(fieldName, (Color32)fieldValue);
        }
        else if (fieldType == typeof(Gradient))
        {
            newValue = InternalEditorGUILayout.GradientField(new GUIContent(fieldName), (Gradient)fieldValue);
        }
        else if (fieldType == typeof(AnimationCurve))
        {
            newValue = EditorGUILayout.CurveField(fieldName, (AnimationCurve)fieldValue);
        }
        else if (fieldType.IsSubclassOf(typeof(Enum)))
        {
            newValue = EditorGUILayout.EnumPopup(fieldName, (Enum)fieldValue);
        }
        else if (fieldType == typeof(Rect))
        {
            newValue = EditorGUILayout.RectField(fieldName, (Rect)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (fieldType == typeof(RectInt))
        {
            newValue = EditorGUILayout.RectIntField(fieldName, (RectInt)fieldValue);
        }
#endif
        else if (fieldType.IsSubclassOf(typeof(UnityEngine.Object)))
        {
            newValue = EditorGUILayout.ObjectField(fieldName, (UnityEngine.Object)fieldValue, fieldType, true);
        }
        else
        {
            GUILayout.Label(fieldType + " " + fieldName);
            newValue = fieldValue;
        }



        //          EditorGUILayout.BoundsField()
        //          EditorGUILayout.ColorField
        //          EditorGUILayout.CurveField
        //          EditorGUILayout.EnumPopup
        //          EditorGUILayout.EnumMaskField
        //          EditorGUILayout.IntSlider // If there's a range attribute maybe?
        //          EditorGUILayout.LabelField // what's this?
        //          EditorGUILayout.ObjectField
        //          EditorGUILayout.RectField
        //          EditorGUILayout.TextArea
        //          EditorGUILayout.TextField

        // What's this? public static void HelpBox (string message, MessageType type, bool wide)
        // What's this?         public static bool InspectorTitlebar (bool foldout, Object targetObj)

        return(newValue);
    }
Esempio n. 11
0
 public override double Double(GUIContent content, double value, Layout option)
 {
     return(EditorGUILayout.DoubleField(content, value, option));
 }
Esempio n. 12
0
 public object DrawAndGetNewValue(Type memberType, string memberName, object value, Entity entity, int index, IComponent component)
 {
     return(EditorGUILayout.DoubleField(memberName, (double)value));
 }
 public VisitStatus Visit <TContainer>(Property <TContainer, double> property, ref TContainer container, ref double value)
 {
     value = EditorGUILayout.DoubleField(GetDisplayName(property), value);
     return(VisitStatus.Stop);
 }
Esempio n. 14
0
        public static bool DrawLayoutField(object value, string label)
        {
            GUI.enabled = false;

            bool isDrawn   = false;
            Type valueType = value.GetType();

            if (valueType == typeof(int))
            {
                isDrawn = true;
                EditorGUILayout.IntField(label, (int)value);
            }
            else if (valueType == typeof(long))
            {
                isDrawn = true;
                EditorGUILayout.LongField(label, (long)value);
            }
            else if (valueType == typeof(float))
            {
                isDrawn = true;
                EditorGUILayout.FloatField(label, (float)value);
            }
            else if (valueType == typeof(double))
            {
                isDrawn = true;
                EditorGUILayout.DoubleField(label, (double)value);
            }
            else if (valueType == typeof(string))
            {
                isDrawn = true;
                EditorGUILayout.TextField(label, (string)value);
            }
            else if (valueType == typeof(Vector2))
            {
                isDrawn = true;
                EditorGUILayout.Vector2Field(label, (Vector2)value);
            }
            else if (valueType == typeof(Vector3))
            {
                isDrawn = true;
                EditorGUILayout.Vector3Field(label, (Vector3)value);
            }
            else if (valueType == typeof(Vector4))
            {
                isDrawn = true;
                EditorGUILayout.Vector4Field(label, (Vector4)value);
            }
            else if (valueType == typeof(Color))
            {
                isDrawn = true;
                EditorGUILayout.ColorField(label, (Color)value);
            }
            else if (valueType == typeof(Bounds))
            {
                isDrawn = true;
                EditorGUILayout.BoundsField(label, (Bounds)value);
            }
            else if (valueType == typeof(Rect))
            {
                isDrawn = true;
                EditorGUILayout.RectField(label, (Rect)value);
            }
            else
            {
                isDrawn = false;
            }

            GUI.enabled = true;

            return(isDrawn);
        }
Esempio n. 15
0
 public static void FrameCountField(string label, ref int Value)
 {
     Value = (int)(EditorGUILayout.DoubleField(label, Value / (double)LockstepManager.FrameRate) * LockstepManager.FrameRate);
 }
 void ICustomVisit <double> .CustomVisit(double f)
 {
     DoField(Property, f, (label, val) => EditorGUILayout.DoubleField(label, val));
 }
Esempio n. 17
0
 public static void FixedNumberField(GUIContent content, int Rounding, ref long Value)
 {
     Value = FixedMath.Create(EditorGUILayout.DoubleField(content, Math.Round(FixedMath.ToDouble(Value), Rounding, MidpointRounding.AwayFromZero)));
 }
Esempio n. 18
0
 public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target)
 {
     return(EditorGUILayout.DoubleField(memberName, (double)value));
 }
Esempio n. 19
0
        public static Vector3 DistanceVector3Field(Vector3 value, bool multiLine, GUILayoutOption[] options = null)
        {
            var distanceUnit = RealtimeCSG.CSGSettings.DistanceUnit;
            var nextUnit     = Units.CycleToNextUnit(distanceUnit);
            var unitText     = Units.GetUnitGUIContent(distanceUnit);

            bool modified          = false;
            bool clickedUnitButton = false;

            var areaWidth = EditorGUIUtility.currentViewWidth;

            const float minWidth         = 65;
            const float vectorLabelWidth = 12;

            var allWidth = (12 * 3) + (Width22Value * 3) + (minWidth * 3);

            Vector3 realValue = value;

            multiLine = multiLine || (allWidth >= areaWidth);
            if (multiLine)
            {
                GUILayout.BeginVertical();
            }
            var originalLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = vectorLabelWidth;
            GUILayout.BeginHorizontal();
            {
                EditorGUI.BeginChangeCheck();
                {
                    value.x = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(VectorXContent, Units.UnityToDistanceUnit(distanceUnit, value.x), options));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    realValue.x = value.x;                     // don't want to introduce math errors unless we actually modify something
                    modified    = true;
                }
                if (multiLine)
                {
                    clickedUnitButton = GUILayout.Button(unitText, EditorStyles.miniLabel, Width22) || clickedUnitButton;
                }
                if (multiLine)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                EditorGUI.BeginChangeCheck();
                {
                    value.y = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(VectorYContent, Units.UnityToDistanceUnit(distanceUnit, value.y), options));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    realValue.y = value.y;                     // don't want to introduce math errors unless we actually modify something
                    modified    = true;
                }
                if (multiLine)
                {
                    clickedUnitButton = GUILayout.Button(unitText, EditorStyles.miniLabel, Width22) || clickedUnitButton;
                }
                if (multiLine)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                EditorGUI.BeginChangeCheck();
                {
                    value.z = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(VectorZContent, Units.UnityToDistanceUnit(distanceUnit, value.z), options));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    realValue.z = value.z;                     // don't want to introduce math errors unless we actually modify something
                    modified    = true;
                }
                clickedUnitButton = GUILayout.Button(unitText, EditorStyles.miniLabel, Width22) || clickedUnitButton;
            }
            GUILayout.EndHorizontal();
            EditorGUIUtility.labelWidth = originalLabelWidth;
            if (multiLine)
            {
                GUILayout.EndVertical();
            }
            if (clickedUnitButton)
            {
                distanceUnit = nextUnit;
                RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                RealtimeCSG.CSGSettings.UpdateSnapSettings();
                RealtimeCSG.CSGSettings.Save();
                RepaintAll();
            }
            GUI.changed = modified;
            return(realValue);
        }
Esempio n. 20
0
        public void OnGUI()
        {
            // If we have a dedicated parameter editor, let it do all the work.
            if (m_ParameterEditor != null)
            {
                EditorGUI.BeginChangeCheck();
                m_ParameterEditor.OnGUI();
                if (EditorGUI.EndChangeCheck())
                {
                    ReadParameterValuesFrom(m_ParameterEditor.target);
                    onChange?.Invoke();
                }
                return;
            }

            // Otherwise, fall back to our default logic.
            if (m_Parameters == null)
            {
                return;
            }
            for (var i = 0; i < m_Parameters.Length; i++)
            {
                var parameter = m_Parameters[i];
                var label     = m_ParameterLabels[i];

                EditorGUI.BeginChangeCheck();

                object result = null;
                if (parameter.isEnum)
                {
                    var intValue = parameter.value.value.ToInt32();
                    result = EditorGUILayout.IntPopup(label, intValue, parameter.enumNames, parameter.enumValues);
                }
                else if (parameter.value.type == TypeCode.Int64 || parameter.value.type == TypeCode.UInt64)
                {
                    var longValue = parameter.value.value.ToInt64();
                    result = EditorGUILayout.LongField(label, longValue);
                }
                else if (parameter.value.type.IsInt())
                {
                    var intValue = parameter.value.value.ToInt32();
                    result = EditorGUILayout.IntField(label, intValue);
                }
                else if (parameter.value.type == TypeCode.Single)
                {
                    var floatValue = parameter.value.value.ToSingle();
                    result = EditorGUILayout.FloatField(label, floatValue);
                }
                else if (parameter.value.type == TypeCode.Double)
                {
                    var floatValue = parameter.value.value.ToDouble();
                    result = EditorGUILayout.DoubleField(label, floatValue);
                }
                else if (parameter.value.type == TypeCode.Boolean)
                {
                    var boolValue = parameter.value.value.ToBoolean();
                    result = EditorGUILayout.Toggle(label, boolValue);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    parameter.value.value = PrimitiveValue.FromObject(result).ConvertTo(parameter.value.type);
                    m_Parameters[i]       = parameter;
                    onChange?.Invoke();
                }
            }
        }
Esempio n. 21
0
        public static bool Field_Layout(object value, string label)
        {
            GUI.enabled = false;

            bool isDrawn   = true;
            Type valueType = value.GetType();

            if (valueType == typeof(bool))
            {
                EditorGUILayout.Toggle(label, (bool)value);
            }
            else if (valueType == typeof(int))
            {
                EditorGUILayout.IntField(label, (int)value);
            }
            else if (valueType == typeof(long))
            {
                EditorGUILayout.LongField(label, (long)value);
            }
            else if (valueType == typeof(float))
            {
                EditorGUILayout.FloatField(label, (float)value);
            }
            else if (valueType == typeof(double))
            {
                EditorGUILayout.DoubleField(label, (double)value);
            }
            else if (valueType == typeof(string))
            {
                EditorGUILayout.TextField(label, (string)value);
            }
            else if (valueType == typeof(Vector2))
            {
                EditorGUILayout.Vector2Field(label, (Vector2)value);
            }
            else if (valueType == typeof(Vector3))
            {
                EditorGUILayout.Vector3Field(label, (Vector3)value);
            }
            else if (valueType == typeof(Vector4))
            {
                EditorGUILayout.Vector4Field(label, (Vector4)value);
            }
            else if (valueType == typeof(Color))
            {
                EditorGUILayout.ColorField(label, (Color)value);
            }
            else if (valueType == typeof(Bounds))
            {
                EditorGUILayout.BoundsField(label, (Bounds)value);
            }
            else if (valueType == typeof(Rect))
            {
                EditorGUILayout.RectField(label, (Rect)value);
            }
            else if (typeof(UnityEngine.Object).IsAssignableFrom(valueType))
            {
                EditorGUILayout.ObjectField(label, (UnityEngine.Object)value, valueType, true);
            }
            else if (valueType.BaseType == typeof(Enum))
            {
                EditorGUILayout.EnumPopup(label, (Enum)value);
            }
            else
            {
                isDrawn = false;
            }

            GUI.enabled = true;

            return(isDrawn);
        }
 public bool CustomUIVisit <TContainer>(ref TContainer container, ref VisitContext <double> context)
     where TContainer : IPropertyContainer
 {
     return(DoField(ref container, ref context, (label, val) => EditorGUILayout.DoubleField(label, val)));
 }
Esempio n. 23
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        MonoBehaviourAdapter.Adaptor clr = target as MonoBehaviourAdapter.Adaptor;
        var instance = clr.ILInstance;

        if (instance != null)
        {
            EditorGUILayout.LabelField("Script", clr.ILInstance.Type.Name);

            //如果JBehaviour
            var JBehaviourType = Init.appdomain.LoadedTypes["JEngine.Core.JBehaviour"];
            var t = instance.Type.ReflectionType;
            if (t.IsSubclassOf(JBehaviourType.ReflectionType))
            {
                var f  = t.GetField("_instanceID", BindingFlags.NonPublic);
                var id = f.GetValue(instance).ToString();
                EditorGUILayout.TextField("InstanceID", id);

                this.fadeGroup[0].target = EditorGUILayout.Foldout(this.fadeGroup[0].target,
                                                                   "JBehaviour Stats", true);
                if (EditorGUILayout.BeginFadeGroup(this.fadeGroup[0].faded))
                {
                    var  fm        = t.GetField("FrameMode", BindingFlags.Public);
                    bool frameMode = EditorGUILayout.Toggle("FrameMode", (bool)fm.GetValue(instance));
                    fm.SetValue(instance, frameMode);

                    var fq        = t.GetField("Frequency", BindingFlags.Public);
                    int frequency = EditorGUILayout.IntField("Frequency", (int)fq.GetValue(instance));
                    fq.SetValue(instance, frequency);

                    GUI.enabled = false;

                    var paused = t.GetField("Paused", BindingFlags.NonPublic);
                    EditorGUILayout.Toggle("Paused", (bool)paused.GetValue(instance));

                    var totalTime = t.GetField("TotalTime", BindingFlags.Public);
                    EditorGUILayout.FloatField("TotalTime", (float)totalTime.GetValue(instance));

                    var loopDeltaTime = t.GetField("LoopDeltaTime", BindingFlags.Public);
                    EditorGUILayout.FloatField("LoopDeltaTime", (float)loopDeltaTime.GetValue(instance));

                    var loopCounts = t.GetField("LoopCounts", BindingFlags.Public);
                    EditorGUILayout.LongField("LoopCounts", (long)loopCounts.GetValue(instance));

                    GUI.enabled = true;

                    var timeScale = t.GetField("TimeScale", BindingFlags.Public);
                    var ts        = EditorGUILayout.FloatField("TimeScale", (float)timeScale.GetValue(instance));
                    timeScale.SetValue(instance, ts);
                }

                EditorGUILayout.EndFadeGroup();

                if (instance.Type.FieldMapping.Count > 0)
                {
                    EditorGUILayout.Space(10);
                    EditorGUILayout.HelpBox($"{t.Name} variables", MessageType.Info);
                }
            }

            int index = 0;
            foreach (var i in instance.Type.FieldMapping)
            {
                //这里是取的所有字段,没有处理不是public的
                var name = i.Key;
                var type = instance.Type.FieldTypes[index];
                index++;

                var    cType = type.TypeForCLR;
                object obj   = instance[i.Value];
                if (cType.IsPrimitive) //如果是基础类型
                {
                    GUI.enabled = true;
                    try
                    {
                        if (cType == typeof(float))
                        {
                            instance[i.Value] = EditorGUILayout.FloatField(name, (float)instance[i.Value]);
                        }
                        else if (cType == typeof(double))
                        {
                            instance[i.Value] = EditorGUILayout.DoubleField(name, (float)instance[i.Value]);
                        }
                        else if (cType == typeof(int))
                        {
                            instance[i.Value] = EditorGUILayout.IntField(name, (int)instance[i.Value]);
                        }
                        else if (cType == typeof(long))
                        {
                            instance[i.Value] = EditorGUILayout.LongField(name, (long)instance[i.Value]);
                        }
                        else if (cType == typeof(bool))
                        {
                            var result = bool.TryParse(instance[i.Value].ToString(), out var value);
                            if (!result)
                            {
                                value = instance[i.Value].ToString() == "1";
                            }

                            instance[i.Value] = EditorGUILayout.Toggle(name, value);
                        }
                        else
                        {
                            EditorGUILayout.LabelField(name, instance[i.Value].ToString());
                        }
                    }
                    catch (Exception e)
                    {
                        Log.PrintError($"无法序列化{name},{e.Message}");
                        EditorGUILayout.LabelField(name, instance[i.Value].ToString());
                    }
                }
                else
                {
                    if (cType == typeof(string))
                    {
                        if (obj != null)
                        {
                            instance[i.Value] = EditorGUILayout.TextField(name, (string)instance[i.Value]);
                        }
                        else
                        {
                            instance[i.Value] = EditorGUILayout.TextField(name, "");
                        }
                    }
                    else if (cType == typeof(JsonData)) //可以折叠显示Json数据
                    {
                        if (instance[i.Value] != null)
                        {
                            this.fadeGroup[1].target = EditorGUILayout.Foldout(this.fadeGroup[1].target, name, true);
                            if (EditorGUILayout.BeginFadeGroup(this.fadeGroup[1].faded))
                            {
                                instance[i.Value] = EditorGUILayout.TextArea(
                                    ((JsonData)instance[i.Value]).ToString()
                                    );
                            }

                            EditorGUILayout.EndFadeGroup();
                            EditorGUILayout.Space();
                        }
                        else
                        {
                            EditorGUILayout.LabelField(name, "暂无值的JsonData");
                        }
                    }
                    else if (typeof(UnityEngine.Object).IsAssignableFrom(cType))
                    {
                        if (obj == null && cType.GetInterfaces().Contains(typeof(CrossBindingAdaptorType)))
                        {
                            EditorGUILayout.LabelField(name, "未赋值的热更类");
                            break;
                        }

                        if (cType.GetInterfaces().Contains(typeof(CrossBindingAdaptorType)))
                        {
                            try
                            {
                                var clrInstance = (MonoBehaviour)Tools.FindObjectsOfTypeAll <CrossBindingAdaptorType>()
                                                  .Find(adaptor =>
                                                        adaptor.ILInstance == instance[i.Value]);
                                GUI.enabled = true;
                                EditorGUILayout.ObjectField(name, clrInstance, cType, true);
                                GUI.enabled = false;
                            }
                            catch
                            {
                                EditorGUILayout.LabelField(name, "未赋值的热更类");
                            }

                            break;
                        }

                        //处理Unity类型
                        var res = EditorGUILayout.ObjectField(name, obj as UnityEngine.Object, cType, true);
                        instance[i.Value] = res;
                    }
                    //可绑定值,可以尝试更改
                    else if (type.ReflectionType.ToString().Contains("BindableProperty") && obj != null)
                    {
                        PropertyInfo fi  = type.ReflectionType.GetProperty("Value");
                        object       val = fi.GetValue(obj);

                        string genericTypeStr = type.ReflectionType.ToString().Split('`')[1].Replace("1<", "")
                                                .Replace(">", "");
                        Type genericType = Type.GetType(genericTypeStr);
                        if (genericType == null ||
                            (!genericType.IsPrimitive && genericType != typeof(string))) //不是基础类型或字符串
                        {
                            EditorGUILayout.LabelField(name, val.ToString());            //只显示字符串
                        }
                        else
                        {
                            //可更改
                            var data = Tools.ConvertSimpleType(EditorGUILayout.TextField(name, val.ToString()),
                                                               genericType);
                            if (data != null) //尝试更改
                            {
                                fi.SetValue(obj, data);
                            }
                        }
                    }
                    else
                    {
                        //其他类型现在没法处理
                        if (obj != null)
                        {
                            if (cType.GetInterfaces().Contains(typeof(CrossBindingAdaptorType))) //需要跨域继承的普遍都有适配器
                            {
                                var clrInstance = (MonoBehaviour)Tools.FindObjectsOfTypeAll <CrossBindingAdaptorType>()
                                                  .Find(adaptor =>
                                                        adaptor.ILInstance.Equals(instance[i.Value]));
                                if (clrInstance != null)
                                {
                                    GUI.enabled = true;
                                    EditorGUILayout.ObjectField(name, clrInstance.gameObject, typeof(GameObject), true);
                                    GUI.enabled = false;
                                }
                            }
                            else //不需要跨域继承的,也有可能以ClassBind挂载
                            {
                                var clrInstance = Tools.FindObjectsOfTypeAll <MonoBehaviourAdapter.Adaptor>()
                                                  .Find(adaptor =>
                                                        adaptor.ILInstance.Equals(instance[i.Value]));
                                if (clrInstance != null)
                                {
                                    GUI.enabled = true;
                                    EditorGUILayout.ObjectField(name, clrInstance, typeof(MonoBehaviourAdapter.Adaptor),
                                                                true);
                                    GUI.enabled = false;
                                }
                                else
                                {
                                    EditorGUILayout.LabelField(name, obj.ToString());
                                }
                            }
                        }
                        else
                        {
                            EditorGUILayout.LabelField(name, "(null)");
                        }
                    }
                }
            }
        }

        // 应用属性修改
        this.serializedObject.ApplyModifiedProperties();
    }
Esempio n. 24
0
        void DrawLayerFilter(SerializedProperty propertyFilters, int index)
        {
            var property           = propertyFilters.GetArrayElementAtIndex(index);
            var filterOperatorProp = property.FindPropertyRelative("filterOperator");

            EditorGUILayout.BeginVertical();

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(new GUIContent {
                text = "Key", tooltip = "Name of the property to use as key. This property is case sensitive."
            }, GUILayout.MaxWidth(150));


            switch ((LayerFilterOperationType)filterOperatorProp.enumValueIndex)
            {
            case LayerFilterOperationType.IsEqual:
            case LayerFilterOperationType.IsGreater:
            case LayerFilterOperationType.IsLess:
                EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
                EditorGUILayout.LabelField(numValueGui, GUILayout.MaxWidth(100));
                break;

            case LayerFilterOperationType.Contains:
                EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
                EditorGUILayout.LabelField(strValueGui, GUILayout.MaxWidth(100));
                break;

            case LayerFilterOperationType.IsInRange:
                EditorGUILayout.LabelField(operatorGui, GUILayout.MaxWidth(150));
                EditorGUILayout.LabelField(minValueGui, GUILayout.MaxWidth(100));
                EditorGUILayout.LabelField(maxValueGui, GUILayout.MaxWidth(100));
                break;

            default:
                break;
            }

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            property.FindPropertyRelative("Key").stringValue = EditorGUILayout.TextField(property.FindPropertyRelative("Key").stringValue, GUILayout.MaxWidth(150));
            filterOperatorProp.enumValueIndex = EditorGUILayout.Popup(filterOperatorProp.enumValueIndex, filterOperatorProp.enumDisplayNames, GUILayout.MaxWidth(150));

            switch ((LayerFilterOperationType)filterOperatorProp.enumValueIndex)
            {
            case LayerFilterOperationType.IsEqual:
            case LayerFilterOperationType.IsGreater:
            case LayerFilterOperationType.IsLess:
                property.FindPropertyRelative("Min").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Min").doubleValue, GUILayout.MaxWidth(100));
                break;

            case LayerFilterOperationType.Contains:
                property.FindPropertyRelative("PropertyValue").stringValue = EditorGUILayout.TextField(property.FindPropertyRelative("PropertyValue").stringValue, GUILayout.MaxWidth(150));
                break;

            case LayerFilterOperationType.IsInRange:
                property.FindPropertyRelative("Min").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Min").doubleValue, GUILayout.MaxWidth(100));
                property.FindPropertyRelative("Max").doubleValue = EditorGUILayout.DoubleField(property.FindPropertyRelative("Max").doubleValue, GUILayout.MaxWidth(100));
                break;

            default:
                break;
            }
            if (GUILayout.Button(new GUIContent(" X "), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
            {
                propertyFilters.DeleteArrayElementAtIndex(index);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
Esempio n. 25
0
            public static object DrawParameterInput(Type parameterType, object parameter)
            {
                int defaultWidth = 100;

                if (parameterType == typeof(bool))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayout.Toggle(false));
                    }
                    else
                    {
                        return(EditorGUILayout.Toggle((bool)parameter));
                    }
                }
                else if (parameterType == typeof(char))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayoutExtra.CharField(' ', defaultWidth));
                    }
                    else
                    {
                        return(EditorGUILayoutExtra.CharField((char)parameter, defaultWidth));
                    }
                }
                else if (parameterType == typeof(int))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayout.IntField(0, GUILayout.Width(defaultWidth)));
                    }
                    else
                    {
                        return(EditorGUILayout.IntField((int)parameter, GUILayout.Width(defaultWidth)));
                    }
                }
                else if (parameterType == typeof(double))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayout.DoubleField(0, GUILayout.Width(defaultWidth)));
                    }
                    else
                    {
                        return(EditorGUILayout.DoubleField((double)parameter, GUILayout.Width(defaultWidth)));
                    }
                }
                else if (parameterType == typeof(float))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayout.FloatField(0, GUILayout.Width(defaultWidth)));
                    }
                    else
                    {
                        return(EditorGUILayout.FloatField((float)parameter, GUILayout.Width(defaultWidth)));
                    }
                }
                else if (parameterType == typeof(long))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayout.LongField(0, GUILayout.Width(defaultWidth)));
                    }
                    else
                    {
                        return(EditorGUILayout.LongField((long)parameter, GUILayout.Width(defaultWidth)));
                    }
                }
                else if (parameterType == typeof(string))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayout.TextField("", GUILayout.Width(defaultWidth)));
                    }
                    else
                    {
                        return(EditorGUILayout.TextField((string)parameter, GUILayout.Width(defaultWidth)));
                    }
                }
                else if (parameterType == typeof(UnityEngine.Vector2))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayoutExtra.CleanVector2View(Vector2.zero, defaultWidth));
                    }
                    else
                    {
                        return(EditorGUILayoutExtra.CleanVector2View((Vector2)parameter, defaultWidth));
                    }
                }
                else if (parameterType == typeof(UnityEngine.Vector3))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayoutExtra.CleanVector3View(Vector3.zero, defaultWidth));
                    }
                    else
                    {
                        return(EditorGUILayoutExtra.CleanVector3View((Vector3)parameter, defaultWidth));
                    }
                }
                else if (parameterType == typeof(TextureConverterEditorWindow.PositionOrValue))
                {
                    if (parameter == null)
                    {
                        return(EditorGUILayout.EnumPopup(TextureConverterEditorWindow.PositionOrValue.UseReadPosition, GUILayout.Width(defaultWidth)));
                    }
                    else
                    {
                        return(EditorGUILayout.EnumPopup((TextureConverterEditorWindow.PositionOrValue)parameter, GUILayout.Width(defaultWidth)));
                    }
                }
                else
                {
                    try {
                        return(EditorGUILayout.ObjectField((UnityEngine.Object)parameter, parameterType, false, GUILayout.Width(defaultWidth)));
                    } catch (UnityEngine.ExitGUIException e) {
                        throw e;
                    } catch (Exception e) {
                        Debug.LogWarning(e.Message);
                        throw new System.ArgumentException("Parameterinput has not been implemented for the type \"" + parameterType.FullName + "\" and the default UnityEngine.Object typecast could not be used instead.");
                    }
                }
            }
Esempio n. 26
0
 public static void DrawDouble(string title, ref double value)
 {
     value = EditorGUILayout.DoubleField(title, value);
 }
        static void FreeDrawSettingsGUI(GeneratorFreeDraw generator, bool isSceneGUI)
        {
            var distanceUnit = RealtimeCSG.CSGSettings.DistanceUnit;
            var nextUnit     = Units.CycleToNextUnit(distanceUnit);
            var unitText     = Units.GetUnitGUIContent(distanceUnit);

            GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
            {
                {
                    GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                    {
                        GUILayout.Label(HeightContent, width65);
                        var height = generator.HaveHeight ? generator.Height : GeometryUtility.CleanLength(generator.DefaultHeight);
                        EditorGUI.BeginChangeCheck();
                        {
                            height = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, height)));
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (generator.HaveHeight)
                            {
                                generator.Height = height;
                            }
                            else
                            {
                                generator.DefaultHeight = height;
                            }
                        }
                        if (GUILayout.Button(unitText, EditorStyles.miniLabel, width20))
                        {
                            distanceUnit = nextUnit;
                            RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                            RealtimeCSG.CSGSettings.UpdateSnapSettings();
                            RealtimeCSG.CSGSettings.Save();
                            CSG_EditorGUIUtility.UpdateSceneViews();
                        }
                    }
                    GUILayout.EndHorizontal();
                    TooltipUtility.SetToolTip(HeightTooltip);
                }
                {
                    GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                    {
                        GUILayout.Label(CurveSidesContent, width65);
                        var subdivisions = generator.CurveSides;
                        EditorGUI.BeginChangeCheck();
                        {
                            subdivisions = (uint)Mathf.Clamp(EditorGUILayout.IntField((int)subdivisions), 0, 32);
                        }
                        if (EditorGUI.EndChangeCheck() && generator.CurveSides != subdivisions)
                        {
                            generator.CurveSides = subdivisions;
                        }
                    }
                    GUILayout.EndHorizontal();
                    TooltipUtility.SetToolTip(CurveSidesTooltip);
                }
                {
                    GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                    {
                        EditorGUI.BeginDisabledGroup(!generator.HaveSelectedEdgesOrVertices);
                        {
                            var tangentState = generator.SelectedTangentState;
                            EditorGUI.BeginChangeCheck();
                            {
                                GUILayout.Label(EdgeTypeContent, width65);
                                EditorGUI.showMixedValue = !tangentState.HasValue;
                                tangentState             = (HandleConstraints)EditorGUILayout.EnumPopup(tangentState.HasValue ? tangentState.Value : HandleConstraints.Straight);
                                EditorGUI.showMixedValue = false;
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                generator.SelectedTangentState = tangentState;
                            }
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                    GUILayout.EndHorizontal();
                    TooltipUtility.SetToolTip(EdgeTypeTooltip);
                }
                EditorGUILayout.Space();

                EditorGUI.BeginDisabledGroup(!generator.HaveSelectedEdges);
                {
                    if (GUILayout.Button(SplitSelectedContent))
                    {
                        generator.SplitSelectedEdge();
                    }
                    TooltipUtility.SetToolTip(SplitSelectedTooltip);
                }
                EditorGUI.EndDisabledGroup();

                /*
                 * GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                 * {
                 *      if (isSceneGUI)
                 *              GUILayout.Label(AlphaContent, width75);
                 *      else
                 *              EditorGUILayout.PrefixLabel(AlphaContent);
                 *      var alpha = generator.Alpha;
                 *      EditorGUI.BeginChangeCheck();
                 *      {
                 *              alpha = EditorGUILayout.Slider(alpha, -1.0f, 3.0f);
                 *      }
                 *      if (EditorGUI.EndChangeCheck() && generator.Alpha != alpha)
                 *      {
                 *              generator.Alpha = alpha;
                 *      }
                 * }
                 * GUILayout.EndHorizontal();
                 */
            }
            GUILayout.EndVertical();
        }
Esempio n. 28
0
        private static void DrawEditableValue(OSCValue value, ref OSCValue removeValue)
        {
            if (value.Type == OSCValueType.Array)
            {
                DrawEditableArray(value, ref removeValue);
                return;
            }

            var firstColumn  = 40f;
            var secondColumn = 60f;
            var defaultColor = GUI.color;

            // FIRST COLUMN
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical("box");

            GUILayout.Label(string.Format("Tag: {0}", value.Tag), OSCEditorStyles.CenterLabel, GUILayout.Width(firstColumn));

            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginHorizontal();

            if (value.Type == OSCValueType.Blob ||
                value.Type == OSCValueType.Impulse ||
                value.Type == OSCValueType.Null)
            {
                EditorGUILayout.BeginHorizontal("box");
                EditorGUILayout.LabelField(value.Type.ToString(), OSCEditorStyles.CenterLabel);
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.BeginHorizontal("box");
                EditorGUILayout.LabelField(value.Type + ":", GUILayout.Width(secondColumn));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal("box");

                switch (value.Type)
                {
                case OSCValueType.Color:
                    value.ColorValue = EditorGUILayout.ColorField(value.ColorValue);
                    break;

                case OSCValueType.True:
                case OSCValueType.False:
                    value.BoolValue = EditorGUILayout.Toggle(value.BoolValue);
                    break;

                case OSCValueType.Char:
                    var rawString = EditorGUILayout.TextField(value.CharValue.ToString());
                    value.CharValue = rawString.Length > 0 ? rawString[0] : ' ';
                    break;

                case OSCValueType.Int:
                    value.IntValue = EditorGUILayout.IntField(value.IntValue);
                    break;

                case OSCValueType.Double:
                    value.DoubleValue = EditorGUILayout.DoubleField(value.DoubleValue);
                    break;

                case OSCValueType.Long:
                    value.LongValue = EditorGUILayout.LongField(value.LongValue);
                    break;

                case OSCValueType.Float:
                    value.FloatValue = EditorGUILayout.FloatField(value.FloatValue);
                    break;

                case OSCValueType.String:
                    value.StringValue = EditorGUILayout.TextField(value.StringValue);
                    break;

                case OSCValueType.Midi:
                    var midi = value.MidiValue;
                    midi.Channel    = (byte)Mathf.Clamp(EditorGUILayout.IntField(midi.Channel), 0, 255);
                    midi.Status     = (byte)Mathf.Clamp(EditorGUILayout.IntField(midi.Status), 0, 255);
                    midi.Data1      = (byte)Mathf.Clamp(EditorGUILayout.IntField(midi.Data1), 0, 255);
                    midi.Data2      = (byte)Mathf.Clamp(EditorGUILayout.IntField(midi.Data2), 0, 255);
                    value.MidiValue = midi;
                    break;

                default:
                    EditorGUILayout.SelectableLabel(value.Value.ToString(), GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    break;
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginVertical("box");
            GUI.color = Color.red;

            var deleteButton = GUILayout.Button("x", GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.Width(20));

            if (deleteButton)
            {
                removeValue = value;
            }

            GUI.color = defaultColor;
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
        }
Esempio n. 29
0
 public SkillEvent OnGuiEditor(SkillEvent se)
 {
     se.DoubleParams0 = EditorGUILayout.DoubleField("时间参数(帧)", se.DoubleParams0);
     return(se);
 }
Esempio n. 30
0
        static void OnBottomBarGUI(SceneView sceneView)
        {
            var  snapToGrid        = RealtimeCSG.CSGSettings.SnapToGrid;
            var  uniformGrid       = RealtimeCSG.CSGSettings.UniformGrid;
            var  moveSnapVector    = RealtimeCSG.CSGSettings.SnapVector;
            var  rotationSnap      = RealtimeCSG.CSGSettings.SnapRotation;
            var  scaleSnap         = RealtimeCSG.CSGSettings.SnapScale;
            var  showGrid          = RealtimeCSG.CSGSettings.GridVisible;
            var  lockAxisX         = RealtimeCSG.CSGSettings.LockAxisX;
            var  lockAxisY         = RealtimeCSG.CSGSettings.LockAxisY;
            var  lockAxisZ         = RealtimeCSG.CSGSettings.LockAxisZ;
            var  distanceUnit      = RealtimeCSG.CSGSettings.DistanceUnit;
            var  helperSurfaces    = RealtimeCSG.CSGSettings.VisibleHelperSurfaces;
            var  showWireframe     = RealtimeCSG.CSGSettings.IsWireframeShown(sceneView);
            var  updateSurfaces    = false;
            bool wireframeModified = false;

            var viewWidth = sceneView.position.width;

            bool modified = false;

            EditorGUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
            {
                EditorGUI.BeginChangeCheck();
                {
                    var skin = GUIStyleUtility.Skin;
                    if (showGrid)
                    {
                        showGrid = GUILayout.Toggle(showGrid, skin.gridIconOn, EditorStyles.toolbarButton);
                    }
                    else
                    {
                        showGrid = GUILayout.Toggle(showGrid, skin.gridIcon, EditorStyles.toolbarButton);
                    }
                    TooltipUtility.SetToolTip(showGridTooltip);

                    if (viewWidth >= 800)
                    {
                        EditorGUILayout.Space();
                    }

                    if (viewWidth >= 200)
                    {
                        var prevBackgroundColor   = GUI.backgroundColor;
                        var lockedBackgroundColor = skin.lockedBackgroundColor;
                        if (lockAxisX)
                        {
                            GUI.backgroundColor = lockedBackgroundColor;
                        }
                        lockAxisX = !GUILayout.Toggle(!lockAxisX, xLabel, skin.xToolbarButton);
                        if (lockAxisX)
                        {
                            TooltipUtility.SetToolTip(xTooltipOn);
                        }
                        else
                        {
                            TooltipUtility.SetToolTip(xTooltipOff);
                        }
                        GUI.backgroundColor = prevBackgroundColor;

                        if (lockAxisY)
                        {
                            GUI.backgroundColor = lockedBackgroundColor;
                        }
                        lockAxisY = !GUILayout.Toggle(!lockAxisY, yLabel, skin.yToolbarButton);
                        if (lockAxisY)
                        {
                            TooltipUtility.SetToolTip(yTooltipOn);
                        }
                        else
                        {
                            TooltipUtility.SetToolTip(yTooltipOff);
                        }
                        GUI.backgroundColor = prevBackgroundColor;

                        if (lockAxisZ)
                        {
                            GUI.backgroundColor = lockedBackgroundColor;
                        }
                        lockAxisZ = !GUILayout.Toggle(!lockAxisZ, zLabel, skin.zToolbarButton);
                        if (lockAxisZ)
                        {
                            TooltipUtility.SetToolTip(zTooltipOn);
                        }
                        else
                        {
                            TooltipUtility.SetToolTip(zTooltipOff);
                        }
                        GUI.backgroundColor = prevBackgroundColor;
                    }
                }
                modified = EditorGUI.EndChangeCheck() || modified;

                if (viewWidth >= 800)
                {
                    EditorGUILayout.Space();
                }

                EditorGUI.BeginChangeCheck();
                {
                    if (viewWidth >= 475)
                    {
                        if (snapToGrid && viewWidth >= 310)
                        {
                            snapToGrid = GUILayout.Toggle(snapToGrid, GUIStyleUtility.Skin.snappingIconOn, EditorStyles.toolbarButton);
                            TooltipUtility.SetToolTip(snapToGridTooltip);
                            if (viewWidth >= 865)
                            {
                                uniformGrid = GUILayout.Toggle(uniformGrid, positionLargeLabel, miniTextStyle);
                            }
                            else
                            {
                                uniformGrid = GUILayout.Toggle(uniformGrid, positionSmallLabel, miniTextStyle);
                            }
                            TooltipUtility.SetToolTip(positionTooltip);
                        }
                        else
                        {
                            snapToGrid = GUILayout.Toggle(snapToGrid, GUIStyleUtility.Skin.snappingIcon, EditorStyles.toolbarButton);
                            TooltipUtility.SetToolTip(snapToGridTooltip);
                        }
                    }
                }
                modified = EditorGUI.EndChangeCheck() || modified;
                if (viewWidth >= 310)
                {
                    if (snapToGrid)
                    {
                        if (uniformGrid || viewWidth < 515)
                        {
                            EditorGUI.showMixedValue = !(moveSnapVector.x == moveSnapVector.y && moveSnapVector.x == moveSnapVector.z);
                            EditorGUI.BeginChangeCheck();
                            {
                                moveSnapVector.x = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, moveSnapVector.x), textInputStyle, MinSnapWidth, MaxSnapWidth));
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                modified         = true;
                                moveSnapVector.y = moveSnapVector.x;
                                moveSnapVector.z = moveSnapVector.x;
                            }
                            EditorGUI.showMixedValue = false;
                        }
                        else
                        {
                            EditorGUI.BeginChangeCheck();
                            {
                                moveSnapVector.x = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, moveSnapVector.x), textInputStyle, MinSnapWidth, MaxSnapWidth));
                                moveSnapVector.y = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, moveSnapVector.y), textInputStyle, MinSnapWidth, MaxSnapWidth));
                                moveSnapVector.z = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, moveSnapVector.z), textInputStyle, MinSnapWidth, MaxSnapWidth));
                            }
                            modified = EditorGUI.EndChangeCheck() || modified;
                        }
                        DistanceUnit nextUnit = Units.CycleToNextUnit(distanceUnit);
                        GUIContent   unitText = Units.GetUnitGUIContent(distanceUnit);
                        if (GUILayout.Button(unitText, miniTextStyle))
                        {
                            distanceUnit = nextUnit;
                            modified     = true;
                        }
                        if (viewWidth >= 700)
                        {
                            if (GUILayout.Button(positionPlusLabel, EditorStyles.miniButtonLeft))
                            {
                                GridUtility.DoubleGridSize(); moveSnapVector = RealtimeCSG.CSGSettings.SnapVector;
                            }
                            TooltipUtility.SetToolTip(positionPlusTooltip);
                            if (GUILayout.Button(positionMinusLabel, EditorStyles.miniButtonRight))
                            {
                                GridUtility.HalfGridSize(); moveSnapVector = RealtimeCSG.CSGSettings.SnapVector;
                            }
                            TooltipUtility.SetToolTip(positionMinnusTooltip);
                        }
                        if (viewWidth >= 750)
                        {
                            if (viewWidth >= 865)
                            {
                                GUILayout.Label(angleLargeLabel, miniTextStyle);
                            }
                            else
                            {
                                GUILayout.Label(angleSmallLabel, miniTextStyle);
                            }
                            TooltipUtility.SetToolTip(angleTooltip);
                        }
                        EditorGUI.BeginChangeCheck();
                        {
                            rotationSnap = EditorGUILayout.FloatField(rotationSnap, textInputStyle, MinSnapWidth, MaxSnapWidth);
                            if (viewWidth <= 750)
                            {
                                TooltipUtility.SetToolTip(angleTooltip);
                            }
                        }
                        modified = EditorGUI.EndChangeCheck() || modified;

                        if (viewWidth >= 370)
                        {
                            GUILayout.Label(angleUnitLabel, miniTextStyle);
                        }
                        if (viewWidth >= 700)
                        {
                            if (GUILayout.Button(anglePlusLabel, EditorStyles.miniButtonLeft))
                            {
                                rotationSnap *= 2.0f; modified = true;
                            }
                            TooltipUtility.SetToolTip(anglePlusTooltip);
                            if (GUILayout.Button(angleMinusLabel, EditorStyles.miniButtonRight))
                            {
                                rotationSnap /= 2.0f; modified = true;
                            }
                            TooltipUtility.SetToolTip(angleMinnusTooltip);
                        }

                        if (viewWidth >= 750)
                        {
                            if (viewWidth >= 865)
                            {
                                GUILayout.Label(scaleLargeLabel, miniTextStyle);
                            }
                            else
                            {
                                GUILayout.Label(scaleSmallLabel, miniTextStyle);
                            }
                            TooltipUtility.SetToolTip(scaleTooltip);
                        }
                        EditorGUI.BeginChangeCheck();
                        {
                            scaleSnap = EditorGUILayout.FloatField(scaleSnap, textInputStyle, MinSnapWidth, MaxSnapWidth);
                            if (viewWidth <= 750)
                            {
                                TooltipUtility.SetToolTip(scaleTooltip);
                            }
                        }
                        modified = EditorGUI.EndChangeCheck() || modified;
                        if (viewWidth >= 370)
                        {
                            GUILayout.Label(scaleUnitLabel, miniTextStyle);
                        }
                        if (viewWidth >= 700)
                        {
                            if (GUILayout.Button(scalePlusLabel, EditorStyles.miniButtonLeft))
                            {
                                scaleSnap *= 10.0f; modified = true;
                            }
                            TooltipUtility.SetToolTip(scalePlusTooltip);
                            if (GUILayout.Button(scaleMinusLabel, EditorStyles.miniButtonRight))
                            {
                                scaleSnap /= 10.0f; modified = true;
                            }
                            TooltipUtility.SetToolTip(scaleMinnusTooltip);
                        }
                    }
                }

                if (viewWidth >= 750)
                {
                    GUILayout.FlexibleSpace();
                }
                EditorGUI.BeginChangeCheck();
                if (showWireframe)
                {
                    showWireframe = GUILayout.Toggle(showWireframe, GUIStyleUtility.Skin.wireframe, EditorStyles.toolbarButton);
                }
                else
                {
                    showWireframe = GUILayout.Toggle(showWireframe, GUIStyleUtility.Skin.wireframeOn, EditorStyles.toolbarButton);
                }
                TooltipUtility.SetToolTip(showWireframeTooltip);
                if (EditorGUI.EndChangeCheck())
                {
                    wireframeModified = true;
                    modified          = true;
                }

                if (viewWidth >= 250)
                {
                    EditorGUI.BeginChangeCheck();
                    {
                        helperSurfaces = (HelperSurfaceFlags)EditorGUILayout.MaskField((int)helperSurfaces, helperSurfaceFlagStrings, EnumMaxWidth, EnumMinWidth);
                        TooltipUtility.SetToolTip(helperSurfacesTooltip);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        updateSurfaces = true;
                        modified       = true;
                    }
                }

                if (viewWidth >= 800)
                {
                    EditorGUILayout.Space();
                }

                if (GUILayout.Button(GUIStyleUtility.Skin.rebuildIcon, EditorStyles.toolbarButton))
                {
                    Debug.Log("Starting complete rebuild");
                    InternalCSGModelManager.skipRefresh = true;
                    RealtimeCSG.CSGSettings.Reload();
                    SceneViewEventHandler.UpdateDefines();

                    var startTime = EditorApplication.timeSinceStartup;
                    InternalCSGModelManager.Rebuild();
                    InternalCSGModelManager.OnHierarchyModified();
                    var hierarchy_update_endTime = EditorApplication.timeSinceStartup;

                    CSGBindings.RebuildAll();
                    var csg_endTime = EditorApplication.timeSinceStartup;

                    InternalCSGModelManager.UpdateMeshes();
                    MeshInstanceManager.UpdateHelperSurfaceVisibility();
                    var meshupdate_endTime = EditorApplication.timeSinceStartup;

                    updateSurfaces = true;
                    SceneViewEventHandler.ResetUpdateRoutine();
                    RealtimeCSG.CSGSettings.Save();
                    InternalCSGModelManager.skipRefresh = false;
                    Debug.Log(string.Format(CultureInfo.InvariantCulture,
                                            "Full hierarchy rebuild in {0:F} ms. Full CSG rebuild done in {1:F} ms. Mesh update done in {2:F} ms.",
                                            (hierarchy_update_endTime - startTime) * 1000,
                                            (csg_endTime - hierarchy_update_endTime) * 1000,
                                            (meshupdate_endTime - csg_endTime) * 1000
                                            ));
                }
                TooltipUtility.SetToolTip(rebuildTooltip);
            }
            EditorGUILayout.EndHorizontal();

            var mousePoint  = Event.current.mousePosition;
            var currentArea = GUILayoutUtility.GetLastRect();
            int controlID   = GUIUtility.GetControlID(BottomBarEditorOverlayHash, FocusType.Passive, currentArea);

            switch (Event.current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:       { if (currentArea.Contains(mousePoint))
                                              {
                                                  GUIUtility.hotControl = controlID; GUIUtility.keyboardControl = controlID; Event.current.Use();
                                              }
                                              break; }

            case EventType.MouseMove:       { if (currentArea.Contains(mousePoint))
                                              {
                                                  Event.current.Use();
                                              }
                                              break; }

            case EventType.MouseUp:         { if (GUIUtility.hotControl == controlID)
                                              {
                                                  GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; Event.current.Use();
                                              }
                                              break; }

            case EventType.MouseDrag:       { if (GUIUtility.hotControl == controlID)
                                              {
                                                  Event.current.Use();
                                              }
                                              break; }

            case EventType.ScrollWheel: { if (currentArea.Contains(mousePoint))
                                          {
                                              Event.current.Use();
                                          }
                                          break; }
            }

            rotationSnap     = Mathf.Max(1.0f, Mathf.Abs((360 + (rotationSnap % 360))) % 360);
            moveSnapVector.x = Mathf.Max(1.0f / 1024.0f, moveSnapVector.x);
            moveSnapVector.y = Mathf.Max(1.0f / 1024.0f, moveSnapVector.y);
            moveSnapVector.z = Mathf.Max(1.0f / 1024.0f, moveSnapVector.z);

            scaleSnap = Mathf.Max(MathConstants.MinimumScale, scaleSnap);

            RealtimeCSG.CSGSettings.SnapToGrid   = snapToGrid;
            RealtimeCSG.CSGSettings.SnapVector   = moveSnapVector;
            RealtimeCSG.CSGSettings.SnapRotation = rotationSnap;
            RealtimeCSG.CSGSettings.SnapScale    = scaleSnap;
            RealtimeCSG.CSGSettings.UniformGrid  = uniformGrid;
//			RealtimeCSG.Settings.SnapVertex					= vertexSnap;
            RealtimeCSG.CSGSettings.GridVisible           = showGrid;
            RealtimeCSG.CSGSettings.LockAxisX             = lockAxisX;
            RealtimeCSG.CSGSettings.LockAxisY             = lockAxisY;
            RealtimeCSG.CSGSettings.LockAxisZ             = lockAxisZ;
            RealtimeCSG.CSGSettings.DistanceUnit          = distanceUnit;
            RealtimeCSG.CSGSettings.VisibleHelperSurfaces = helperSurfaces;

            if (wireframeModified)
            {
                RealtimeCSG.CSGSettings.SetWireframeShown(sceneView, showWireframe);
            }

            if (updateSurfaces)
            {
                MeshInstanceManager.UpdateHelperSurfaceVisibility();
            }

            if (modified)
            {
                GUI.changed = true;
                RealtimeCSG.CSGSettings.UpdateSnapSettings();
                RealtimeCSG.CSGSettings.Save();
                SceneView.RepaintAll();
            }
        }