//add behabiour of type t to state public void AddBehaviour(System.Type t) { if (!t.IsSubclassOf(typeof(StateBehaviour))) { return; } SODatabase.Add(state, (StateBehaviour)CreateInstance(t), state.behaviours); fold.Add(true); }
public void Add(System.Type varType) { if (!varType.IsSubclassOf(typeof(Variable))) { return; } Variable v = (Variable)CreateInstance(varType); SODatabase.Add(varHandle, v, varHandle.Variables); v.name = "Variable"; fold.Add(true); }
private void CreateScorerOptions() { newScorerType = AISEditorUtil.allScorers[EditorGUILayout.Popup("New Scorer Type:", AISEditorUtil.allScorers.IndexOf(newScorerType), AISEditorUtil.allScorers.Select(x => x.Name).ToArray())]; if (GUILayout.Button("Create new Scorer")) { AISScorer scorer = CreateInstance(newScorerType) as AISScorer; if (scorer != null) { scorer.name = "New"; scorer.owner = this; SODatabase.Add(this, scorer, scorers); } } }
private void CreateChildOptions() { GUILayout.BeginHorizontal(); newChildType = AISEditorUtil.allActions[EditorGUILayout.Popup("New Child Type:", AISEditorUtil.allActions.IndexOf(newChildType), AISEditorUtil.allActions.Select(x => x.Name).ToArray())]; if (GUILayout.Button("Create new child")) { AISAction child = CreateInstance(newChildType) as AISAction; if (child != null) { child.name = "New"; child.order = order + 1; child.parent = this; child.ai = ai; SODatabase.Add(this, child, children); } } GUILayout.EndHorizontal(); }
void OnGUI() { GUILayout.BeginVertical(); item = EditorGUILayout.ObjectField("Item: ", item, typeof(Item), false) as Item; if (item) { item.OnGui(); GUILayout.BeginHorizontal(); newCompType = Item.allComponents[EditorGUILayout.Popup(Item.allComponents.IndexOf(newCompType), Item.allComponents.ToArray())]; if (GUILayout.Button("Create component")) { ItemComponent c = CreateInstance(newCompType) as ItemComponent; if (c) { c.item = item; c.name = "New " + c.GetType().ToString(); SODatabase.Add(item, c, item.components); } } GUILayout.EndHorizontal(); if (GUILayout.Button("Save")) { EditorUtility.SetDirty(item); foreach (ItemComponent c in item.components) { EditorUtility.SetDirty(c); } } } else { EditorGUILayout.LabelField("Choose an Item"); item = Selection.activeObject as Item; } GUILayout.EndVertical(); }
public void Add(ScriptableObject key, ScriptableObject value) { SODatabase.Add(this, value, key, dic); EditorUtility.SetDirty(this); }
void AddVar(AISVariable var) { var.name = "New Var"; SODatabase.Add(ai, var, ai.variables); }