public static void Init(string newBuildingType) { buildingType = newBuildingType; NamePopupWindow window = ScriptableObject.CreateInstance <NamePopupWindow>(); window.position = new Rect(Screen.width / 2, Screen.height / 2, 256, 256); window.ShowPopup(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Rect rect = position; rect.height = EditorGUIUtility.singleLineHeight; Vector2 shift_vector = (rect.height + 2) * Vector2.up; bool folded_out = EditorGUI.PropertyField(rect, property, false); rect.position += shift_vector; if (folded_out) { EditorGUI.indentLevel++; EditorGUI.PropertyField(rect, property.FindPropertyRelative("_override_clip")); rect.position += shift_vector; SerializedProperty default_name = property.FindPropertyRelative("_default_codename"); GUI.SetNextControlName("Namer"); string typed_value = EditorGUI.TextField(rect, new GUIContent("Default Codename"), default_name.stringValue); if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition)) { active_popup_window = new NamePopupWindow(new Vector2(position.width, 300), property.name, SetDefaultName); PopupWindow.Show(rect, active_popup_window); } rect.position += shift_vector; if (selected_name != "") { default_name.stringValue = selected_name; GUI.FocusControl(null); EditorGUI.FocusTextInControl(null); selected_name = ""; } else { default_name.stringValue = typed_value; } EditorGUI.indentLevel--; } height = rect.y - position.y; }
void SetDefaultName(string new_name) { selected_name = new_name; active_popup_window = null; }
public static void CreateNaturalResourcesBuilding() { NamePopupWindow.Init("NaturalResources"); }
public static void CreateResearchBuilding() { NamePopupWindow.Init("Research"); }
public static void CreateManufacturingBuilding() { NamePopupWindow.Init("Manufacturing"); }
public static void CreateServiceBuilding() { NamePopupWindow.Init("Service"); }