public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (!initialized) { OnEnable(); } if (GUI.Button((RectEditor.GetRect(new Vector2(0, 0), new Vector2(3, 1), position)), "Sort")) { } SerializedProperty SP = property.FindPropertyRelative("a"); EditorGUI.LabelField((RectEditor.GetRect(new Vector2(0, 1), new Vector2(2, 1), position)), "z"); EditorGUI.FloatField((RectEditor.GetRect(new Vector2(2, 1), new Vector2(3, 1), position)), 0); EditorGUI.LabelField((RectEditor.GetRect(new Vector2(0, 2), new Vector2(8, 1), position)), "b"); EditorGUI.FloatField((RectEditor.GetRect(new Vector2(2, 2), new Vector2(6, 1), position)), 0); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (!initialized) { OnEnable(property); } Rect testRect = RectEditor.GetRect(new Vector2(0, 0), new Vector2(10, 1), position); Rect testRect2 = RectEditor.GetRect(new Vector2(0, 2), new Vector2(10, 1), position); Rect testRect3 = RectEditor.GetRect(new Vector2(0, 4), new Vector2(10, 1), position); EditorGUI.LabelField(testRect, "Object Tool"); selectedPopupIndex = EditorGUI.Popup(testRect2, selectedPopupIndex, prefabNamesList.ToArray()); if (PrefabUtility.GetPrefabObject(Selection.activeGameObject)) { if (GUI.Button(testRect3, "Swap")) { Debug.Log(goList[selectedPopupIndex].FullName); //destroy prefab then create new one GameObject.DestroyImmediate(Selection.activeGameObject); Selection.activeGameObject = GameObject.Instantiate(Resources.Load <GameObject>(goList[selectedPopupIndex].FullName) as GameObject); } } else { if (GUI.Button(testRect3, "Create")) { } } /* * // if (Event.current.type == EventType.Repaint) { * //EditorGUI.DrawTextureTransparent(testRect, ); * * //} */ }