private void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused) { DialogProperty property = container.Properties[index]; float x = rect.x; property.type = (DialogProperty.Type)EditorGUI.EnumPopup(new Rect(x, rect.y, 60, EditorGUIUtility.singleLineHeight), property.type); x += 65; property.Name = EditorGUI.TextField(new Rect(x, rect.y, 100, EditorGUIUtility.singleLineHeight), property.Name); x += 105; float propertyWidth = rect.xMax - x; if (property.type == DialogProperty.Type.BOOL) { property.boolValue = EditorGUI.Toggle(new Rect(x, rect.y, propertyWidth, EditorGUIUtility.singleLineHeight), property.boolValue); } else if (property.type == DialogProperty.Type.INT) { property.intValue = EditorGUI.IntField(new Rect(x, rect.y, propertyWidth, EditorGUIUtility.singleLineHeight), property.intValue); } else if (property.type == DialogProperty.Type.FLOAT) { property.floatValue = EditorGUI.FloatField(new Rect(x, rect.y, propertyWidth, EditorGUIUtility.singleLineHeight), property.floatValue); } else { EditorGUILayout.TextField("cant parse value type"); } }
public bool DoesPassCondition(DialogProperty property) { switch (property.type) { case DialogProperty.Type.BOOL: return(DoesPassCondition(property.boolValue)); case DialogProperty.Type.FLOAT: return(DoesPassCondition(property.floatValue)); case DialogProperty.Type.INT: return(DoesPassCondition(property.intValue)); default: throw new ArgumentException(); } }
private void OnDrawElement(Rect rect, int index, bool isactive, bool isfocused) { DialogAnswerCondition condition = answer.conditions[index]; float spacing = rect.width / 2; int propIndex = EditorGUI.Popup(new Rect(rect.x, rect.y, spacing, EditorGUIUtility.singleLineHeight), GetIndexFrom(AvailablePropertyNames(), condition.propertyName), AvailablePropertyNames()); condition.propertyName = GetSelectionByIndex(AvailablePropertyNames(), propIndex); DialogProperty prop = null; try { prop = container.Properties.Find(p => p.Name == condition.propertyName); }catch (ArgumentNullException) {} var r = new Rect(rect.x + (spacing * 1.5f), rect.y, spacing / 2, EditorGUIUtility.singleLineHeight); if (prop != null) { switch (prop.type) { case DialogProperty.Type.BOOL: condition.BoolcompareType = (BoolCondition)EditorGUI.EnumPopup(new Rect(rect.x + spacing, rect.y, spacing / 2, EditorGUIUtility.singleLineHeight), condition.BoolcompareType); condition.boolValue = EditorGUI.Toggle(new Rect(rect.xMax - 15, rect.y, 15, EditorGUIUtility.singleLineHeight), condition.boolValue); break; case DialogProperty.Type.FLOAT: condition.NumcompareType = (NumericCondition)EditorGUI.EnumPopup(new Rect(rect.x + spacing, rect.y, spacing / 2, EditorGUIUtility.singleLineHeight), condition.NumcompareType); condition.floatValue = EditorGUI.FloatField(r, condition.floatValue); break; case DialogProperty.Type.INT: condition.NumcompareType = (NumericCondition)EditorGUI.EnumPopup(new Rect(rect.x + spacing, rect.y, spacing / 2, EditorGUIUtility.singleLineHeight), condition.NumcompareType); condition.intValue = EditorGUI.IntField(r, condition.intValue); break; } } }
set => SetValue(DialogProperty, value);
public object Clone() { DialogContainer container = ScriptableObject.CreateInstance(typeof(DialogContainer)) as DialogContainer; container.Properties = new List <DialogProperty>(); container.Statements = new List <DialogStatement>(); foreach (var property in Properties) { var t = new DialogProperty(); t.Name = property.Name; t.type = property.type; t.boolValue = property.boolValue; t.floatValue = property.floatValue; t.intValue = property.intValue; container.Properties.Add(t); } foreach (var statement in Statements) { var x = ScriptableObject.CreateInstance(typeof(DialogStatement)) as DialogStatement; container.Statements.Add(x); x.Id = statement.Id; x.speaker = statement.speaker; x.text = statement.text; x.name = statement.name; } container.StartingPoint = container.Statements.Find(s => s.Id == StartingPoint.Id); // after all statements are there, do transitions foreach (var statement in Statements) { var x = container.Statements.Find(s => s.Id == statement.Id); x.Answers = new List <DialogAnswer>(); foreach (var answer in statement.Answers) { var y = ScriptableObject.CreateInstance(typeof(DialogAnswer)) as DialogAnswer; y.From = x; y.To = container.Statements.Find(s => s.Id == answer.To.Id); y.title = answer.title; y.parent = container; y.conditions = new List <DialogAnswerCondition>(); foreach (var condition in answer.conditions) { var c = new DialogAnswerCondition(); c.BoolcompareType = condition.BoolcompareType; c.NumcompareType = condition.NumcompareType; c.boolValue = condition.boolValue; c.floatValue = condition.floatValue; c.intValue = condition.intValue; c.type = condition.type; c.propertyName = condition.propertyName; y.conditions.Add(c); } x.Answers.Add(y); } } return(container); }
get => (IFileSystemDialog)GetValue(DialogProperty); set => SetValue(DialogProperty, value);