コード例 #1
0
ファイル: CSerializedNode.cs プロジェクト: Caycay/UnityGames
        // 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);
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: CNodeManager.cs プロジェクト: Caycay/UnityGames
 public bool VerifyNodes(CNode n)
 {
     CNode.allVerified = true;
     if (n == null)
     {
         return(false);
     }
     n.verifyAll();
     return(CNode.allVerified);;
 }
コード例 #5
0
ファイル: CSerializedNode.cs プロジェクト: Caycay/UnityGames
        // 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);
        }
コード例 #6
0
ファイル: CNodeManager.cs プロジェクト: Caycay/UnityGames
 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;
     }
 }
コード例 #7
0
ファイル: CNodeManager.cs プロジェクト: Caycay/UnityGames
        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);
        }
コード例 #8
0
ファイル: CNode.cs プロジェクト: Caycay/UnityGames
 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;
             }
         }
     }
 }
コード例 #9
0
ファイル: CSerializedNode.cs プロジェクト: Caycay/UnityGames
        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);
        }
コード例 #10
0
ファイル: CNodeManager.cs プロジェクト: Caycay/UnityGames
        // 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 ();
        }
コード例 #11
0
ファイル: CSerializedNode.cs プロジェクト: Caycay/UnityGames
 public CSerializedNode(CNode cn)
 {
     fromCnode(cn);
 }
コード例 #12
0
 public CConnection(CNode p, int i, int t)
 {
     parent     = p;
     PosInArray = i;
     Type       = t;
 }
コード例 #13
0
 public void AddPreset(CNode node, Hashtable p, string name)
 {
     presets.Add(new Preset(node, p, name));
 }