// Converts from a CNode to SerializedNode public void fromCnode(CNode cn) { ID = cn.ID; Type = cn.Type; CNodeType = cn.GetType().AssemblyQualifiedName; //cn.CnodeType; //Debug.Log ("Name:" + CNodeType); parameters = cn.parameters; windowx = cn.window.x; windowy = cn.window.y; width = cn.window.width; height = cn.window.height; foreach (CConnection c in cn.Outputs) { if (c.pointer != null) { Outputs.Add(c.ID); Inputs.Add(c.pointer.ID); } } foreach (CConnection c in cn.Bottoms) { if (c.pointer != null) { Outputs.Add(c.ID); Inputs.Add(c.pointer.ID); } } }
public PopupData buildData(PopupData pd, CNode n) { if (pd == null) { pd = new PopupData(); } int cnt = 0; foreach (Preset p in presets) { if (n.GetType().AssemblyQualifiedName == p.NodeID && n.Type == p.NodeType) { cnt++; } } if (pd.presets == null || pd.presets.Length != cnt) { pd.presets = new Preset[cnt]; pd.vals = new string[cnt]; } cnt = 0; foreach (Preset p in presets) { if (n.GetType().AssemblyQualifiedName == p.NodeID && n.Type == p.NodeType) { pd.presets [cnt] = p; pd.vals [cnt] = p.Name; cnt++; } } return(pd); }
public Preset(CNode n, Hashtable par, string name) { Name = name; ID = Random.Range(0, 10000000); NodeID = n.GetType().AssemblyQualifiedName; NodeType = n.Type; parameters = new Hashtable(); CopyFrom(par); }
public bool VerifyNodes(CNode n) { CNode.allVerified = true; if (n == null) { return(false); } n.verifyAll(); return(CNode.allVerified);; }
// Converts to a new node. Automatic class generation. Whoo! public CNode toCnode(int Add) { CNode c = (CNode)System.Activator.CreateInstance(System.Type.GetType(CNodeType)); c.Initialize(ID + Add, Type, (int)windowx, (int)windowy); c.SetupID(); c.parameters = parameters; return(c); }
public void RefreshNodesNew() { foreach (CNode n in nodes) { System.Type t = n.GetType(); CNode newNode = (CNode)System.Activator.CreateInstance(t); newNode.Initialize(findNextN(), n.Type, (int)mousePos.x, (int)mousePos.y); newNode.MirrorParameters(n); n.parameters = newNode.parameters; n.displayParameters = null; } }
public void CountChildNodes(CNode n) { CNode.childrenCount = 0; foreach (CNode c in nodes) { c.counted = false; } n.getInputsChildren(); float cc = CNode.childrenCount - 1; if (cc == 0) { cc = 1; } progressDelta = 1.0f / (float)(cc); }
public void MirrorParameters(CNode other) { foreach (string p in parameters.Keys) { Parameter org = (Parameter)other.parameters[p]; Parameter copy = (Parameter)parameters[p]; //Debug.Log ("Copying :" + p); if (org != null && copy != null) { copy.value = org.value; if (org.label.StartsWith("Color")) { copy.max = org.max; copy.min = org.min; } } } }
public static void LoadSnippet(string fname, ArrayList nodes, int Add) { if (!System.IO.File.Exists(fname)) { return; } ArrayList sn; using (FileStream str = File.OpenRead(fname)) { BinaryFormatter bf = new BinaryFormatter(); sn = (ArrayList)bf.Deserialize(str); } foreach (CSerializedNode cs in sn) { CNode n = cs.toCnode(Add); if (n != null) { nodes.Add(n); } } createLinks(sn, nodes, Add); }
// generic node creation protected void CreateNode(object obj) { MenuType mt = (MenuType)obj; System.Type t = (System.Type)mt.type; if (mt.constrained) { ArrayList l = findType(nodes, t); if (l.Count != 0) { EditorUtility.DisplayDialog("Error", mt.message, "Got it"); return; } } CNode n = (CNode)System.Activator.CreateInstance(t); n.Initialize(findNextN(), mt.val, (int)mousePos.x, (int)mousePos.y); nodes.Add(n); //ResetState (); }
public CSerializedNode(CNode cn) { fromCnode(cn); }
public CConnection(CNode p, int i, int t) { parent = p; PosInArray = i; Type = t; }
public void AddPreset(CNode node, Hashtable p, string name) { presets.Add(new Preset(node, p, name)); }