コード例 #1
0
        public void AddNewAnchor(Color c, int id, bool affectValues = true)
        {
            PWAnchorMultiData tmp          = new PWAnchorMultiData(c);
            PWValues          anchorValues = anchorInstance as PWValues;

            if (c == new Color(0, 0, 0, 0))
            {
                c = PWColorPalette.GetAnchorColorByType(type);
            }
            tmp.name       = (first != null) ? first.name : "";
            tmp.additional = true;
            tmp.id         = id;
            if (anchorValues != null && anchorValues.Count == multipleValueCount)
            {
                multipleValueCount++;
            }
            // Debug.Log("new anchor with id: " + id);
            //add an object to the PWValues list:
            if (affectValues && anchorValues != null)
            {
                anchorValues.Add(null);
            }

            multi.Add(tmp);
        }
コード例 #2
0
        void ProcessNodeLinks(PWNode node)
        {
            var links = node.GetLinks();

            foreach (var link in links)
            {
                if (!nodesDictionary.ContainsKey(link.distantNodeId))
                {
                    continue;
                }

                if (link.mode == PWNodeProcessMode.RequestForProcess)
                {
                    continue;
                }

                var target = nodesDictionary[link.distantNodeId];

                if (target == null)
                {
                    continue;
                }

                // Debug.Log("local: " + link.localClassAQName + " / " + node.GetType() + " / " + node.nodeId);
                // Debug.Log("distant: " + link.distantClassAQName + " / " + target.GetType() + " / " + target.nodeId);

                //ignore old links not removed cause of property removed in a script at compilation
                if (!realMode)
                {
                    if (!bakedNodeFields.ContainsKey(link.localClassAQName) ||
                        !bakedNodeFields[link.localClassAQName].ContainsKey(link.localName) ||
                        !bakedNodeFields[link.distantClassAQName].ContainsKey(link.distantName))
                    {
                        Debug.LogError("Can't find field: " + link.localName + " in " + link.localClassAQName + " OR " + link.distantName + " in " + link.distantClassAQName);
                        continue;
                    }
                }

                var val = bakedNodeFields[link.localClassAQName][link.localName].GetValue(node);
                if (val == null)
                {
                    Debug.Log("null value of node: " + node.GetType() + " of field: " + link.localName);
                }
                var prop = bakedNodeFields[link.distantClassAQName][link.distantName];

                // Debug.Log("set value: " + val.GetHashCode() + "(" + val + ")" + " to " + target.GetHashCode() + "(" + target + ")");

                // simple assignation, without multi-anchor
                if (link.distantIndex == -1 && link.localIndex == -1)
                {
                    if (realMode)
                    {
                        prop.SetValue(target, val);
                    }
                    else
                    {
                        try {
                            prop.SetValue(target, val);
                        } catch (Exception e) {
                            Debug.LogError(e);
                        }
                    }
                }
                else if (link.distantIndex != -1 && link.localIndex == -1)                 //distant link is a multi-anchor
                {
                    PWValues values = (PWValues)prop.GetValue(target);

                    if (values != null)
                    {
                        if (!values.AssignAt(link.distantIndex, val, link.localName))
                        {
                            Debug.Log("failed to set distant indexed field value: " + link.distantName);
                        }
                    }
                }
                else if (link.distantIndex == -1 && link.localIndex != -1 && val != null)                 //local link is a multi-anchor
                {
                    object localVal = ((PWValues)val).At(link.localIndex);

                    if (realMode)
                    {
                        prop.SetValue(target, localVal);
                    }
                    else
                    {
                        try {
                            prop.SetValue(target, localVal);
                        } catch {
                            Debug.LogWarning("can't assign " + link.localName + " to " + link.distantName);
                        }
                    }
                }
                else if (val != null)                 // both are multi-anchors
                {
                    PWValues values   = (PWValues)prop.GetValue(target);
                    object   localVal = ((PWValues)val).At(link.localIndex);

                    if (values != null)
                    {
                        // Debug.Log("assigned total multi");
                        if (!values.AssignAt(link.distantIndex, localVal, link.localName))
                        {
                            Debug.Log("failed to set distant indexed field value: " + link.distantName);
                        }
                    }
                }
            }
        }