private void FieldSprites(List <EnergyBarUGUIBase.SpriteTex> sprites) { var arrayList = new MadGUI.ArrayList <EnergyBarUGUIBase.SpriteTex>(sprites, tex => { FieldSprite(tex, ""); return(tex); }); arrayList.onAdd += tex => tex.color = Color.white; if (arrayList.Draw()) { EditorUtility.SetDirty((target as EnergyBarUGUIBase).gameObject); } }
// private void AtlasTextures(ref SerializedProperty textures, string label) { // if (MadGUI.Foldout(label, true)) { // var list = new MadGUI.ArrayList<EnergyBar3DBase.AtlasTex>(textures, (property) => { // var spriteName = property.FindPropertyRelative("spriteGUID"); // var color = property.FindPropertyRelative("color"); // // AtlasTexture(spriteName, color); // }); // // list.Draw(); // } // } private EnergyBar3DBase.AtlasTex[] AtlasTextures(EnergyBar3DBase.AtlasTex[] textures, string label) { if (MadGUI.Foldout(label, true)) { var l = new List <EnergyBar3DBase.AtlasTex>(); if (textures != null) { l.AddRange(textures); } var list = new MadGUI.ArrayList <EnergyBar3DBase.AtlasTex>(l, (item) => { var spriteGUID = item.spriteGUID; var color = item.color; EditorGUI.BeginChangeCheck(); AtlasTexture(spriteGUID, ref color, (guid) => { item.spriteGUID = guid; EditorUtility.SetDirty(target); }); if (EditorGUI.EndChangeCheck()) { item.spriteGUID = spriteGUID; item.color = color; EditorUtility.SetDirty(target); } return(item); }); list.onAdd += (tex) => tex.color = Color.white; list.Draw(); return(l.ToArray()); } else { return(textures); } }
protected void GUIAnimationRefList(SerializedProperty list, bool showFromTheBeginning) { var alist = new MadGUI.ArrayList<MadAnimator.AnimationRef>(list, (p) => { GUIAnimationRef(p, showFromTheBeginning); }); alist.Draw(); }
// private void AtlasTextures(ref SerializedProperty textures, string label) { // if (MadGUI.Foldout(label, true)) { // var list = new MadGUI.ArrayList<EnergyBar3DBase.AtlasTex>(textures, (property) => { // var spriteName = property.FindPropertyRelative("spriteGUID"); // var color = property.FindPropertyRelative("color"); // // AtlasTexture(spriteName, color); // }); // // list.Draw(); // } // } private EnergyBar3DBase.AtlasTex[] AtlasTextures(EnergyBar3DBase.AtlasTex[] textures, string label) { if (MadGUI.Foldout(label, true)) { var l = new List<EnergyBar3DBase.AtlasTex>(); if (textures != null) { l.AddRange(textures); } var list = new MadGUI.ArrayList<EnergyBar3DBase.AtlasTex>(l, (item) => { var spriteGUID = item.spriteGUID; var color = item.color; EditorGUI.BeginChangeCheck(); AtlasTexture(spriteGUID, ref color, (guid) => { item.spriteGUID = guid; EditorUtility.SetDirty(target); }); if (EditorGUI.EndChangeCheck()) { item.spriteGUID = spriteGUID; item.color = color; EditorUtility.SetDirty(target); } return item; }); list.onAdd += (tex) => tex.color = Color.white; list.Draw(); return l.ToArray(); } else { return textures; } }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); EditorGUILayout.Space(); if (MadGUI.Button("Select Parent Icon", Color.yellow)) { Selection.activeObject = property.icon.gameObject; } EditorGUILayout.Space(); GUILayout.Label("Property", "HeaderLabel"); EditorGUILayout.Space(); MadGUI.Indent(() => { EditorGUILayout.Space(); GUILayout.Label("Property Name: " + property.name); EditorGUILayout.BeginHorizontal(); GUILayout.Label("State"); GUILayout.FlexibleSpace(); if (property.linked) { if (MadGUI.Button("LINKED", Color.cyan, GUILayout.Width(60))) { if (EditorUtility.DisplayDialog( "State Linked", "This property state is linked by '" + property.linkage.name + "' property and cannot be changed directly. Do you want to select the linkage owner?", "Yes", "No")) { Selection.activeObject = property.linkage.gameObject; } } } else if (property.propertyEnabled) { if (MadGUI.Button("On", Color.green, GUILayout.Width(50))) { property.propertyEnabled = false; EditorUtility.SetDirty(property); } } else { if (MadGUI.Button("Off", Color.red, GUILayout.Width(50))) { property.propertyEnabled = true; EditorUtility.SetDirty(property); } } EditorGUILayout.EndHorizontal(); if (property.GetComponent<MadText>() != null) { EditorGUILayout.Space(); MadGUI.PropertyField(textFromProperty, "Text From Property"); MadGUI.ConditionallyEnabled(textFromProperty.boolValue, () => { MadGUI.PropertyField(textPropertyName, "Text Property Name"); }); } }); GUILayout.Label("Connections", "HeaderLabel"); EditorGUILayout.Space(); MadGUI.Indent(() => { bool connectionChanged; GUILayout.Label("Things to show when this property is enabled:"); connectionChanged = new MadGUI.ArrayList<GameObject>(showWhenEnabled, (p) => { MadGUI.PropertyField(p, ""); }).Draw(); if (connectionChanged) { property.icon.ApplyConnections(); } EditorGUILayout.Space(); GUILayout.Label("Things to show when this property is disabled:"); connectionChanged = new MadGUI.ArrayList<GameObject>(showWhenDisabled, (p) => { MadGUI.PropertyField(p, ""); }).Draw(); if (connectionChanged) { property.icon.ApplyConnections(); } }); serializedObject.ApplyModifiedProperties(); }
private void GUIModifiers(SerializedProperty listProperty) { var list = new MadGUI.ArrayList<MadLevelAnimator.Modifier>(listProperty, (p) => { GUIModifier(p); }); list.Draw(); }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); MadGUI.PropertyField(draggable, "Draggable", MadGUI.ObjectIsSet); MadGUI.PropertyField(startDepth, "Start Depth", "Depth value of first layer added. " + "Every next layer will receive +1 to it's depth value."); MadGUI.PropertyField(ignoreXMovement, "Ignore X Movement"); MadGUI.PropertyField(ignoreYMovement, "Ignore Y Movement"); serializedObject.ApplyModifiedProperties(); MadGUI.Info("Add new layers, then select them to edit properties for each layer."); var arrayList = new MadGUI.ArrayList<MadLevelBackgroundLayer>(script.layers, (layer) => { if (layer == null) { return null; } var so = new SerializedObject(layer); so.UpdateIfDirtyOrScript(); var texture = so.FindProperty("texture"); EditorGUILayout.BeginHorizontal(); MadGUI.PropertyField(texture, ""); MadGUI.ConditionallyEnabled(CanMoveUp(layer), () => { if (GUILayout.Button("Up")) { MoveUp(layer); } }); MadGUI.ConditionallyEnabled(CanMoveDown(layer), () => { if (GUILayout.Button("Down")) { MoveDown(layer); } }); GUI.color = Color.yellow; if (GUILayout.Button("Select")) { Selection.activeGameObject = layer.gameObject; } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (so.ApplyModifiedProperties()) { layer.SetDirty(); } return layer; }); arrayList.addLabel = "Add Layer"; arrayList.emptyLabel = "There are currently no layers."; arrayList.createFunctionGeneric = () => { var layer = MadTransform.CreateChild<MadLevelBackgroundLayer>(script.transform, "layer (empty)"); layer.GetComponent<MadSprite>().hideFlags = HideFlags.HideInInspector; return layer; }; arrayList.onRemove = (layer) => layer.Cleanup(); arrayList.beforeAdd = () => { MadUndo.RecordObject(script, "Add Background Layer"); MadUndo.LegacyRegisterSceneUndo("Add Background Layer"); }; arrayList.beforeRemove = (arg) => { MadUndo.RecordObject(script, "Remove Background Layer"); MadUndo.LegacyRegisterSceneUndo("Remove Background Layer"); }; if (arrayList.Draw()) { EditorUtility.SetDirty(script); } EditorGUI.BeginChangeCheck(); if (EditorGUI.EndChangeCheck()) { // changed } }