Ejemplo n.º 1
0
 void Init(PWAnchorField anchorField)
 {
     if (anchorField == null)
     {
         Debug.LogWarning("Null anchor field passed to Anchor at deserialization");
     }
     anchorFieldRef = anchorField;
     color          = anchorField.color;
     nodeRef        = anchorField.nodeRef;
 }
Ejemplo n.º 2
0
        //called only once (when the anchor is created)
        public void Initialize(PWAnchorField anchorField)
        {
            GUID = System.Guid.NewGuid().ToString();
            Init(anchorField);

            //if we can have multiple anchors, we set the fieldIndex value
            if (anchorField.multiple)
            {
                fieldIndex = anchorField.anchors.Count;
            }
        }
Ejemplo n.º 3
0
        static void FindAnchors(PWAnchorField fromAnchorField, PWAnchorField toAnchorField, out PWAnchor fromAnchor, out PWAnchor toAnchor)
        {
            if (fromAnchorField.multiple)
            {
                fromAnchor = fromAnchorField.anchors.Find(a => a.linkCount == 0);
            }
            else
            {
                fromAnchor = fromAnchorField.anchors.First();
            }

            if (toAnchorField.multiple)
            {
                toAnchor = toAnchorField.anchors.Find(a => a.linkCount == 0);
            }
            else
            {
                toAnchor = toAnchorField.anchors.First();
            }
        }
Ejemplo n.º 4
0
        public void OnAfterDeserialized(PWAnchorField anchorField)
        {
            Init(anchorField);

            //we use the LinkTable in the graph to get the only instance of link stored
            //	to know why, take a look at the PWGraph.cs file.
            var nodeLinkTable = nodeRef.graphRef.nodeLinkTable;

            //only used when a part of a link was not well destroyed, technically never
            var linkToRemove = new List <string>();

            //here we set the anchor references in the link cauz they can't be serialized.
            foreach (var linkGUID in linkGUIDs)
            {
                var linkInstance = nodeLinkTable.GetLinkFromGUID(linkGUID);

                //if link does not exists, skip it and add it to the remove list
                if (linkInstance == null)
                {
                    linkToRemove.Add(linkGUID);
                    continue;
                }

                links.Add(linkInstance);
            }

            //removes ghost links (normally never appends)
            foreach (var linkGUID in linkToRemove)
            {
                Debug.LogError("[PWAnchor] Removing link GUID " + linkGUID + " from the link list cauz it was destroyed");

                linkGUIDs.Remove(linkGUID);
            }

            //propagate the OnAfterDeserialize event.
            foreach (var link in links)
            {
                link.OnAfterDeserialize(this);
            }
        }