示例#1
0
        public void Awake()
        {
            if (ConstellationBehaviour.eventSystem == null)
            {
                eventSystem = new ConstellationEventSystem();
            }

            if (NodesFactory.Current == null)
            {
                nodeFactory = new NodesFactory();
            }
            else
            {
                nodeFactory = NodesFactory.Current;
            }

            if (ConstellationData == null && Application.isPlaying)
            {
                this.enabled = false;
                Debug.LogError("Constellation Error: No Constellation attached to " + this.gameObject);
                return;
            }
            var nodes = ConstellationData.GetNodes();

            Constellation = new Constellation();
            SetNodes(nodes);

            var links = ConstellationData.GetLinks();

            foreach (LinkData link in links)
            {
                Constellation.AddLink(new Link(Constellation.GetInput(link.Input.Guid),
                                               Constellation.GetOutput(link.Output.Guid),
                                               Constellation.GetOutput(link.Output.Guid).Type), "none");
            }
            SetUnityObject();
            SetConstellationEvents();
            Constellation.Initialize(System.Guid.NewGuid().ToString(), ConstellationData.name);
            Constellation.Awake();
        }