Example #1
0
        void CreateComponent()
        {
            if (!CheckNameViability())
            {
                return;
            }

            var comp = new RTSComponentInfo();

            comp.name       = compName;
            comp.type       = compType;
            comp.aimingData = compAim;

            string path = "RTSComponents/" + window.GetSelectedPage().pageName + '/' + compName;

            //PrefabUtility.
            RTS.Subsys.DataProvider.CreateResourceFolder(path);
            GameObject go = new GameObject("CompTemp", typeof(Unit));

            PrefabUtility.SaveAsPrefabAsset(go, "Assets/Resources/" + path + "/prefab.prefab");
            GameObject.DestroyImmediate(go, false);

            window.selectedComp = window.GetSelectedPage().componentList.Count;
            window.GetSelectedPage().componentList.Add(comp);
            window.OpenCompEditTab();
        }
Example #2
0
            void UpdateCompList()
            {
                EditorUIBase GenCompEntry(int index)
                {
                    var disp = new EHorizontalLayout()
                               + new EText().Content(index.ToString()).Width(20)
                               + new EText().BindContent(() =>
                    {
                        AssetTypes.ComponentDBPage p = window.GetSelectedPage();
                        if (p != null)
                        {
                            if (p.componentList.Count > index)
                            {
                                return(p.componentList[index].name);
                            }
                        }
                        return("OUT OF SCOPE!");
                    }).RelativeSize(true);

                    var tabs    = new ESwitchTab().Height(100);
                    var element = tabs
                                  //Unselected
                                  + (new EButton().OnClicked((EButton b) => { window.selectedComp = index; window.OpenCompEditTab(); })
                                     + disp
                                     )
                    ;

                    element.OnConstruct(window);
                    return(element);
                }

                AssetTypes.ComponentDBPage page = window.GetSelectedPage();

                if (page == null)
                {
                    compList.children.Clear();
                    return;
                }

                if (compList.children.Count < page.componentList.Count)
                {
                    for (int i = compList.children.Count; i < page.componentList.Count; i++)
                    {
                        compList.children.Add(GenCompEntry(i));
                    }
                }
                else if (page.componentList.Count < compList.children.Count)
                {
                    compList.children.RemoveRange(page.componentList.Count, compList.children.Count - page.componentList.Count);
                }
            }