protected override void displayForm() { formScrollPos = EditorGUILayout.BeginScrollView(formScrollPos); EditorGUILayout.BeginVertical(); GUI.enabled = false; databaseID = EditorGUILayout.IntField("Database ID : ", databaseID); GUI.enabled = true; itemName = EditorGUILayout.TextField("Name : ", itemName); itemIcon = (Sprite)EditorGUILayout.ObjectField("Icon : ", itemIcon, typeof(Sprite), false); itemModel = (GameObject)EditorGUILayout.ObjectField("Model : ", itemModel, typeof(GameObject), false); isConsomable = EditorGUILayout.Toggle("Is Consomable : ", isConsomable); isStackable = EditorGUILayout.Toggle("Is Stackable : ", isStackable); if (isStackable) { maxStackableSize = EditorGUILayout.IntField("Max stack size : ", maxStackableSize); } canBeRecycle = EditorGUILayout.Toggle("Can be recycle : ", canBeRecycle); interactableType = (InteractableObjectType)EditorGUILayout.EnumPopup("Interactible type : ", interactableType); itemType = (ItemType)EditorGUILayout.EnumPopup("Item type : ", itemType); targetType = (ItemTargetType)EditorGUILayout.EnumPopup("Target type : ", targetType); numberOfEffect = EditorGUILayout.IntField("Number Of effect :", numberOfEffect); updateEffectsListsSize(numberOfEffect); if (numberOfEffect != 0) { for (int i = 0; i < numberOfEffect; i++) { EditorGUILayout.LabelField("Effect n° " + i + " : ", centerTitle); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Effect :"); effectsIndex[i] = EditorGUILayout.Popup(effectsIndex[i], EffectList.getEffectsNames()); effects[i].effect = EffectList.effects[effectsIndex[i]]; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Value :"); effects[i].value = EditorGUILayout.FloatField(effects[i].value); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Starting time :"); effects[i].usedBy = (EffectUseBy)EditorGUILayout.EnumPopup(effects[i].usedBy); EditorGUILayout.EndHorizontal(); } } displayFormButtons(); EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); setEffectValueByLevelSize(); EditorGUILayout.BeginHorizontal("Box"); EditorGUILayout.LabelField("Ability Effects", new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }); if (GUILayout.Button("Add Effect")) { addEffect(); } EditorGUILayout.EndHorizontal(); for (int i = 0; i < attributs.effectAndValues.Count; i++) { EditorGUILayout.Space(); // effect title EditorGUILayout.BeginHorizontal("Box"); EditorGUILayout.LabelField("Effect n° " + i + " : ", new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }); if (GUILayout.Button(displayEffect[i] ? "Hide" : "Display")) { displayEffect[i] = !displayEffect[i]; } if (GUILayout.Button("Remove") && EditorUtility.DisplayDialog("Are you sure ?", "Do you want to delete this ?", "Yes", "No")) { removeEffect(i); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel += 2; // hide or display effect if (displayEffect[i]) { effectsIndex[i] = EditorGUILayout.Popup("Effect : ", effectsIndex[i], EffectList.getEffectsNames()); attributs.effectAndValues[i].element = (Element)EditorGUILayout.EnumPopup("Effect Element :", attributs.effectAndValues[i].element); attributs.effectAndValues[i].effectType = (EffectUseBy)EditorGUILayout.EnumPopup("Effect used by :", attributs.effectAndValues[i].effectType); // value by level EditorGUILayout.LabelField("Value by Level :", new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }); for (int j = 0; j < attributs.effectAndValues[i].valuesByLevel.Count; j++) { attributs.effectAndValues[i].valuesByLevel[j] = EditorGUILayout.FloatField("Value for level " + (i + 1) + " : ", attributs.effectAndValues[i].valuesByLevel[j]); } // stat types EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Stat Types", new GUIStyle(GUI.skin.label) { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }); if (GUILayout.Button("Add")) { attributs.effectAndValues[i].statTypes.addEmptyElement(); } EditorGUILayout.EndHorizontal(); for (int j = 0; j < attributs.effectAndValues[i].statTypes.Count; j++) { EditorGUILayout.BeginHorizontal(); attributs.effectAndValues[i].statTypes[j] = (StatType)EditorGUILayout.EnumPopup(attributs.effectAndValues[i].statTypes[j]); if (GUILayout.Button("Remove")) { if (EditorUtility.DisplayDialog("Are you sure ?", "Do you want to delete this ?", "Yes", "No")) { attributs.effectAndValues[i].statTypes.RemoveAt(j); } } EditorGUILayout.EndHorizontal(); } } EditorGUI.indentLevel -= 2; } }