public override void OnInspectorGUI() { float width = EditorGUIUtility.currentViewWidth; Physicbody physicbody = target as Physicbody; Styles(); serializedObject.Update(); if (GUILayout.Button(displayInfos ? "Fold" : "Unfold")) { displayInfos = !displayInfos; } if (displayInfos) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Acceleration : ", infoTitleStyle, GUILayout.Height(20), GUILayout.Width(width * .4f)); EditorGUILayout.LabelField(physicbody.accelerationMagnitude.ToString("F1"), infoStyle, GUILayout.Height(20), GUILayout.Width(width * .1f)); EditorGUILayout.LabelField(physicbody.acceleration.ToString("F1"), infoStyle, GUILayout.Height(20), GUILayout.Width(width * .5f)); EditorGUILayout.EndHorizontal(); } GUING.Line(1, 5); DrawDefaultInspector(); serializedObject.ApplyModifiedProperties(); }
void DisplayPalette(ColorPalette palette, Rect rect, float colorW, float colorH, int countPerLine = 3) { Texture2D t = new Texture2D((int)rect.width, (int)rect.height); GUILayout.BeginArea(rect, t); //GUING.Title("<b>"+ palette.name + "</b>",false,true); style = new GUIStyle(GUI.skin.textField); style.fontStyle = FontStyle.Bold; style.alignment = TextAnchor.MiddleCenter; palette.name = GUILayout.TextField(palette.name, style, GUILayout.Width(rect.width), GUILayout.Height(16)); GUILayout.BeginHorizontal(); int x = 0; Color gc = GUI.contentColor; style = new GUIStyle(GUI.skin.label); style.fontSize = 10; style.alignment = TextAnchor.MiddleCenter; for (int i = 0; i <= palette.colors.Count; i++) { if (x % countPerLine == 0) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); } if (i < palette.colors.Count) { int variation = palette.variation; if (palette.variation >= palette.colors[i].colors.Count) { palette.colors[i].colors.Add(palette.colors[i].colors[palette.colors[i].colors.Count - 1]); } GUILayout.BeginVertical(); Couleur couleur = palette.colors[i]; Color c = GUI.backgroundColor; GUI.backgroundColor = couleur.colors[variation]; couleur.name = GUILayout.TextField(palette.colors[i].name, style, GUILayout.Width(colorW), GUILayout.Height(15)); if (!selecting) { couleur.colors[variation] = EditorGUILayout.ColorField(GUIContent.none, palette.colors[i].colors[variation], false, false, false, GUILayout.Width(colorW), GUILayout.Height(colorH)); } else if (GUILayout.Button("", GUILayout.Width(colorW), GUILayout.Height(colorH))) { PlayerData.cacheColorName = ((int)Random.Range(9999, 999999)).ToString(); PlayerData.SetColor(PlayerData.cacheColorName, couleur.colors[variation]); inspector.paleting = 2; this.Close(); } palette.colors[i] = couleur; GUI.backgroundColor = c; GUILayout.EndVertical(); } else { GUILayout.BeginVertical(); GUILayout.Label("NEW", style, GUILayout.Width(colorW)); style = new GUIStyle(GUI.skin.button); style.fontSize = 35; style.alignment = TextAnchor.MiddleCenter; GUI.contentColor = Color.white; if (GUILayout.Button("+", style, GUILayout.Width(colorW), GUILayout.Height(colorH))) { palette.colors.Add(new Couleur("color")); } GUILayout.EndVertical(); } x += 1; } GUILayout.EndHorizontal(); GUI.contentColor = gc; palette.variation = (int)GUING.Slider(palette.variation, 0, 5, 1, new Vector2(0, 0), "Variation " + palette.variation, rect.width * 0.95f); GUING.Line(2, 0.1f); GUILayout.BeginHorizontal(); if (GUILayout.Button("<")) { palette.order--; } style = new GUIStyle(GUI.skin.label); style.fontSize = 8; style.alignment = TextAnchor.MiddleCenter; GUILayout.Label((-palette.order).ToString(), style, GUILayout.Width(50)); if (GUILayout.Button(">")) { palette.order++; } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); return; float width = EditorGUIUtility.currentViewWidth; Styles(); serializedObject.Update(); var value = serializedObject.FindProperty("_value"); var max = serializedObject.FindProperty("_max"); var min = serializedObject.FindProperty("_min"); var transformsRefs = serializedObject.FindProperty("transformsRefs"); var transformsMaxs = serializedObject.FindProperty("transformsMaxs"); var transformsMins = serializedObject.FindProperty("transformsMins"); var transformsSpeeds = serializedObject.FindProperty("transformsSpeeds"); var slidersRef = serializedObject.FindProperty("slidersRef"); var slidersSpeeds = serializedObject.FindProperty("slidersSpeeds"); var updateDelay = serializedObject.FindProperty("updateDelay"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("MIN ", GUILayout.Width(width / 3f)); EditorGUILayout.LabelField("-- value --", GUILayout.Width(width / 3f)); EditorGUILayout.LabelField(" MAX", GUILayout.Width(width / 3f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); min.floatValue = EditorGUILayout.FloatField(min.floatValue); value.floatValue = EditorGUILayout.FloatField(value.floatValue); max.floatValue = EditorGUILayout.FloatField(max.floatValue); EditorGUILayout.EndHorizontal(); GUING.Line(1, 1); EditorGUILayout.BeginHorizontal(); transformsRefs.arraySize = EditorGUILayout.IntField(transformsRefs.arraySize, GUILayout.Width(width * .2f)); transformsMaxs.arraySize = transformsRefs.arraySize; transformsMins.arraySize = transformsRefs.arraySize; transformsSpeeds.arraySize = transformsRefs.arraySize; EditorGUILayout.Space(); EditorGUILayout.LabelField("Min Scale", GUILayout.Width(width * .25f)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Max Scale", GUILayout.Width(width * .25f)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Move Speed", GUILayout.Width(width * .25f)); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); for (int i = 0; i < transformsRefs.arraySize; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("°", GUILayout.Width(width * .025f)); EditorGUILayout.PropertyField(transformsRefs.GetArrayElementAtIndex(i), GUIContent.none, GUILayout.Width(width * .2f)); EditorGUILayout.Space(); transformsMins.GetArrayElementAtIndex(i).vector3Value = EditorGUILayout.Vector3Field("", transformsMins.GetArrayElementAtIndex(i).vector3Value, GUILayout.Width(width * .25f)); EditorGUILayout.Space(); transformsMaxs.GetArrayElementAtIndex(i).vector3Value = EditorGUILayout.Vector3Field("", transformsMaxs.GetArrayElementAtIndex(i).vector3Value, GUILayout.Width(width * .25f)); EditorGUILayout.Space(); transformsSpeeds.GetArrayElementAtIndex(i).floatValue = EditorGUILayout.FloatField(transformsSpeeds.GetArrayElementAtIndex(i).floatValue, GUILayout.Width(width * .075f)); EditorGUILayout.EndHorizontal(); } /* * EditorGUILayout.PropertyField( transformsRefs,GUILayout.Width( width) ); EditorGUILayout.Space(); * transformsMaxs.arraySize = transformsRefs.arraySize; transformsMins.arraySize = transformsRefs.arraySize; transformsSpeeds.arraySize = transformsRefs.arraySize; * EditorGUILayout.PropertyField( transformsMaxs , GUILayout.Width( width ) ); EditorGUILayout.Space(); * EditorGUILayout.PropertyField( transformsMins , GUILayout.Width( width ) ); EditorGUILayout.Space(); * EditorGUILayout.PropertyField( transformsSpeeds , GUILayout.Width( width ) ); */ serializedObject.ApplyModifiedProperties(); }