void OnGUI() { EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(); { UserName = EditorGUILayout.TextField("Name", UserName); ServerKind = (Server.Name)EditorGUILayout.EnumPopup("Server", ServerKind); CampKind = (Camp.Name)EditorGUILayout.EnumPopup("Camp", CampKind); RacesKind = (Races.Name)EditorGUILayout.EnumPopup("Races", RacesKind); SexKind = (Sex.Name)EditorGUILayout.EnumPopup("Sex", SexKind); ClassesKind = (Classes.Name)EditorGUILayout.EnumPopup("Classes", ClassesKind); EditorGUILayout.EndVertical(); if (GUILayout.Button("Clear")) { } } } EditorGUILayout.EndHorizontal(); g = (GameObject)EditorGUILayout.ObjectField("GameObject", g, typeof(GameObject), false); m = (MonoBehaviour)EditorGUILayout.ObjectField("MonoBehaviour", m, typeof(MonoBehaviour), false); if (GUILayout.Button("Add Part of Player")) { /* * foreach(KeyValuePair<> val in PartsOfPlayer) * { * * } */ } if (GUILayout.Button("Make Player")) { GameObject playerObject = GameObject.Find("Player"); if (playerObject) { DestroyImmediate(playerObject); playerObject = null; } GameObject cameraObject = GameObject.FindWithTag("MainCamera"); if (cameraObject) { Destroy(cameraObject); cameraObject = null; } playerObject = PrefabLoader.LoadPrefab(PrefabLoader.cCharacter, "Player", new Vector3(0, 0.5f, 0)); } } EditorGUILayout.EndVertical(); }
void OnGUI() { EditorGUILayout.HelpBox("Simple dynamic list editor.\nPress Enter to apply field changes.", MessageType.Info); EditorGUILayout.BeginVertical(); { ScrollPosition = EditorGUILayout.BeginScrollView(ScrollPosition); ClassesKind = (Classes.Name)EditorGUILayout.EnumPopup("Classes", ClassesKind); foreach (Skill val in skills) { EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(); { val.Name = EditorGUILayout.TextField("Name", val.Name); val.UseDistance = EditorGUILayout.FloatField("UseDistance", val.UseDistance); val.CooldownDuration = EditorGUILayout.FloatField("CooldownDuration", val.CooldownDuration); val.Cooldown = EditorGUILayout.FloatField("Cooldown", val.Cooldown); val.CastingDuration = EditorGUILayout.FloatField("CastingDuration", val.CastingDuration); val.Casting = EditorGUILayout.FloatField("CastingTime", val.Casting); } EditorGUILayout.EndVertical(); val.Icon = (Sprite)EditorGUILayout.ObjectField("Sprite", val.Icon, typeof(Sprite), false); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } } if (GUILayout.Button("Add Skill")) { skills.Add(new Skill()); } if (GUILayout.Button("Create Skill")) { GameObject skillCanvas = PrefabLoader.LoadPrefab(PrefabLoader.cSkills, "SkillCanvas"); skillBook = PrefabLoader.LoadPrefab(PrefabLoader.cSkills, "SkillBook"); GameObject skillWindow = PrefabLoader.LoadPrefab(PrefabLoader.cSkills, "SkillWindow"); GameObject cooldownManager = PrefabLoader.LoadPrefab(PrefabLoader.cSkills, "CooldownManager"); castingBar = PrefabLoader.LoadPrefab(PrefabLoader.cSkills, "CastingBar"); skillCanvas.AddChild(skillBook, new Vector3(-150f, 78, 0), new Vector2(682, 462)); skillCanvas.AddChild(skillWindow); skillCanvas.AddChild(cooldownManager); skillCanvas.AddChild(castingBar); for (int i = 0; i < skills.Count; i++) { GameObject skillObject = PrefabLoader.LoadPrefab(PrefabLoader.cSkills, "SkillObject"); skillObject.GetComponent <Image>().sprite = skills[i].Icon; skillObject.GetComponent <Button>().image.sprite = skills[i].Icon; skillObject.GetComponent <Button>().onClick.AddListener(skillObject.GetComponent <CoolDown>().StartCoolDown); skillObject.GetComponent <CoolDown>().icon = skillObject.GetComponent <Image>(); skillObject.GetComponent <CoolDown>().duration = skills[i].CooldownDuration; skillObject.GetComponent <CoolDown>().cooldown = 0f; skillObject.GetComponent <CoolDown>().castingBar = castingBar.GetComponent <Slider>(); skillObject.GetComponent <CoolDown>().castingDuration = skills[i].CastingDuration; skillObject.GetComponent <CoolDown>().castingTime = 0f; skillObject.transform.GetChild(0).GetComponentInChildren <Image>().sprite = skills[i].Icon; skillBook.AddChild(skillObject); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }