void OnGUI() { baseToolbar = GUILayout.Toolbar(baseToolbar, baseToolberStrings); if (baseToolbar == 0) { BeginWindows(); //windowRect = GUILayout.Window(1, windowRect, NodeEditorWindow.Ope, "Hi There"); EndWindows(); } else { // GUILayout.BeginArea(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); toolbarInt = GUILayout.SelectionGrid(toolbarInt, toolbarStrings, 1, GUILayout.Width(buttonWidth + 20)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); if (toolbarInt == 0) { EditorGUI.BeginChangeCheck(); database = (TechnologyData)EditorGUILayout.ObjectField("Database:", database, typeof(TechnologyData), allowSceneObjects: false, GUILayout.Width(propertyLength)); if (EditorGUI.EndChangeCheck()) { technologies = database.Technologies; } ScriptableObject target = this; SerializedObject so = new SerializedObject(target); SerializedProperty stringsProperty = so.FindProperty("technologies"); EditorGUILayout.PropertyField(stringsProperty, true, GUILayout.Width(propertyLength)); so.ApplyModifiedProperties(); EditorGUILayout.BeginHorizontal(); // if (GUILayout.Button("Load")) { // technologies = database.Technologies; // } if (GUILayout.Button("Save And Update", GUILayout.Width(buttonWidth))) { database.Technologies = technologies; PopulateSelectionGrid(); } if (GUILayout.Button("Undo", GUILayout.Width(buttonWidth))) { technologies = database.Technologies; } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Update Toolbar", GUILayout.Width(buttonWidth * 2 + 5))) { PopulateSelectionGrid(); } } else { EditorStyles.textField.wordWrap = true; for (int i = 0; i < technologies.Length; i++) { PopulateTechnologies(i); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } void PopulateTechnologies(int i) { if (i + 1 == toolbarInt) { techNames[i] = EditorGUILayout.TextField("Technology Name:", techNames[i], GUILayout.Width(propertyLength)); descrptions[i] = EditorGUILayout.TextField("Description:", descrptions[i], GUILayout.Width(propertyLength), GUILayout.MaxHeight(50)); sprites[i] = (Sprite)EditorGUILayout.ObjectField("Sprite:", sprites[i], typeof(Sprite), allowSceneObjects: true, GUILayout.Width(propertyLength)); researchCosts[i] = EditorGUILayout.IntField("Research Cost:", researchCosts[i], GUILayout.Width(propertyLength)); techTypes[i] = TechGUI(i); // Commod if (techTypes[i] == TechnologyCard.TechType.Commodity) { commodities[i] = (CommodityData)EditorGUILayout.ObjectField("Commodity:", commodities[i], typeof(CommodityData), allowSceneObjects: true, GUILayout.Width(propertyLength)); if (commodities[i] != null) { PopulateCommodities(i); } } else if (techTypes[i] == TechnologyCard.TechType.CommodityModifier) { PopulateCommodities(i); modifiers[i] = EditorGUILayout.IntField("Efficency Modifier:", modifiers[i], GUILayout.Width(propertyLength)); } //Commod name EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save", GUILayout.Width(248))) { technologies[i].techName = techNames[i]; } if (GUILayout.Button("Undo", GUILayout.Width(248))) { AssignToTempVariables(i); } EditorGUILayout.EndHorizontal(); } } }
void Awake() { database = (TechnologyData)AssetDatabase.LoadAssetAtPath("Assets/Data/Technology/TechnologyDatabase.asset", typeof(TechnologyData)); technologies = database.Technologies; PopulateSelectionGrid(); }