Exemplo n.º 1
0
        void SaveStartUpGroup()
        {
            if (Selection.activeGameObject == null)
            {
                return;
            }
            var objectsParent = Selection.activeTransform;

            experimentData.elements.Clear();
            GameObject    pfb;
            GameObject    item;
            RunTimeElemet element;

            for (int i = 0; i < objectsParent.childCount; i++)// (Transform item in objectsParent)
            {
                item = objectsParent.GetChild(i).gameObject;
                //pfb = PrefabUtility.GetPrefabObject(item) as GameObject;
                pfb = PrefabUtility.GetPrefabParent(item) as GameObject;
                if (pfb == null)
                {
                    EditorUtility.DisplayDialog("警告", item.name + "对象未制作预制体", "确认");
                    break;
                }
                element          = new RunTimeElemet();
                element.name     = pfb.name;
                element.element  = pfb;
                element.id       = i;
                element.position = item.transform.position;
                element.rotation = item.transform.rotation;
                experimentData.elements.Add(element);
            }
        }
Exemplo n.º 2
0
        public void ReStart()
        {
            ResatToBeginState();

            GameObject item;
            IElement   element;

            for (int i = 0; i < elements.Count; i++)
            {
                RunTimeElemet runele = elements[i];
                item      = GameObject.Instantiate(runele.element, runele.position, runele.rotation) as GameObject;
                item.name = runele.name;
                element   = item.GetComponent <IElement>();
                if (element != null)
                {
                    created.Add(element.Go);
                    if (element is ITube)
                    {
                        var tube = element as ITube;
                        tube.onExport += OnReact;

                        if (element is IContainer)
                        {
                            var container = element as IContainer;
                            container.onComplete    += OnOneStep;
                            container.onGetSupports += GetSupporter;
                            containers.Add(container);
                        }
                    }
                    else if (element is ISupporter)
                    {
                        supporters.Add(element as ISupporter);
                    }
                }
            }
        }