public void ReloadChange() { selectedGraph = 0; bcg = null; BocsCyclesNodeManager.Reset(); if (Selection.activeGameObject != null) { bcg = Selection.activeGameObject.GetComponent <BocsCyclesMaterial>(); if (bcg != null) { graphType = GraphType.Material; LoadNodes(); return; } bcg = Selection.activeGameObject.GetComponent <BocsCyclesLight>(); if (bcg != null) { graphType = GraphType.Light; LoadNodes(); return; } bcg = Selection.activeGameObject.GetComponent <BocsCyclesCamera>(); if (bcg != null) { graphType = GraphType.World; LoadNodes(); return; } } }
protected void OnDestroy() { SaveNodes(); bcg = null; selectedGraph = 0; graphType = GraphType.None; }
private static void _addShaderGraph(XmlTextWriter xml, BocsCyclesGraphBase graph, string name) { string saved = BocsCyclesNodeManager.SaveGraph(); for (int graphIndex = 0; graphIndex < graph.GetGraphCount(); graphIndex++) { BocsCyclesNodeManager.LoadGraph(graph.GetGraph(graphIndex)); if (name != string.Empty) { xml.WriteStartElement("shader"); xml.WriteAttributeString("name", name + graphIndex); } for (int nid = 0; nid < BocsCyclesNodeManager.Nodes.Count; nid++) { BocsNodeBase n = BocsCyclesNodeManager.Nodes[nid]; if (n.NodeName == "output") { continue; //shaders have one by default } xml.WriteStartElement(n.NodeName); xml.WriteAttributeString("name", n.NodeName + nid); for (int sid = 0; sid < n.Slots.Count; sid++) { BocsSlotBase slot = n.Slots[sid]; string val = slot.GetXML(); if (val != string.Empty) { xml.WriteAttributeString(slot.SlotName, val); } } xml.WriteEndElement(); } for (int nid = 0; nid < BocsCyclesNodeManager.Nodes.Count; nid++) { BocsNodeBase n = BocsCyclesNodeManager.Nodes[nid]; for (int sid = 0; sid < n.Slots.Count; sid++) { BocsSlotBase slot = n.Slots[sid]; foreach (BocsSlotBase c in slot.OutputSlots) { int toID = BocsCyclesNodeManager.FindNodeFromSlot(c); BocsNodeBase toNode = BocsCyclesNodeManager.Nodes[toID]; string toConnect = "output"; if (toNode.NodeName != "output") { toConnect = toNode.NodeName + toID; } xml.WriteStartElement("connect"); xml.WriteAttributeString("from", n.NodeName + nid + " " + slot.SlotName); xml.WriteAttributeString("to", toConnect + " " + c.SlotName); xml.WriteEndElement(); } } } if (name != string.Empty) { xml.WriteEndElement(); } } BocsCyclesNodeManager.LoadGraph(saved); }