public static EditorUnitList LoadUnit() { GameObject obj=Resources.Load("PrefabList/UnitListPrefab", typeof(GameObject)) as GameObject; if(obj==null) obj=CreatePrefab(); UnitListPrefab prefab=obj.GetComponent<UnitListPrefab>(); if(prefab==null) prefab=obj.AddComponent<UnitListPrefab>(); for(int i=0; i<prefab.unitList.Count; i++){ if(prefab.unitList[i]==null){ prefab.unitList.RemoveAt(i); i-=1; } } string[] nameList=new string[prefab.unitList.Count]; for(int i=0; i<prefab.unitList.Count; i++){ if(prefab.unitList[i]!=null){ nameList[i]=prefab.unitList[i].unitName; //prefab.unitList[i].prefabID=i; unitIDList.Add(prefab.unitList[i].prefabID); } } EditorUnitList eUnitList=new EditorUnitList(); eUnitList.prefab=prefab; eUnitList.nameList=nameList; return eUnitList; }
public static void Init() { // Get existing open window or if none, make a new one: window = (UnitTBManagerWindow)EditorWindow.GetWindow(typeof (UnitTBManagerWindow)); window.minSize=new Vector2(375, 449); window.maxSize=new Vector2(375, 800); EditorUnitList eUnitList=LoadUnit(); prefab=eUnitList.prefab; unitList=prefab.unitList; foreach(UnitTB unit in unitList){ unitIDList.Add(unit.prefabID); } }
public static void Init() { // Get existing open window or if none, make a new one: window = (UnitTBManagerWindow)EditorWindow.GetWindow(typeof(UnitTBManagerWindow)); window.minSize = new Vector2(375, 449); window.maxSize = new Vector2(375, 800); EditorUnitList eUnitList = LoadUnit(); prefab = eUnitList.prefab; unitList = prefab.unitList; foreach (UnitTB unit in unitList) { unitIDList.Add(unit.prefabID); } }
public static EditorUnitList LoadUnit() { GameObject obj = Resources.Load("PrefabList/UnitListPrefab", typeof(GameObject)) as GameObject; if (obj == null) { obj = CreatePrefab(); } UnitListPrefab prefab = obj.GetComponent <UnitListPrefab>(); if (prefab == null) { prefab = obj.AddComponent <UnitListPrefab>(); } for (int i = 0; i < prefab.unitList.Count; i++) { if (prefab.unitList[i] == null) { prefab.unitList.RemoveAt(i); i -= 1; } } string[] nameList = new string[prefab.unitList.Count]; for (int i = 0; i < prefab.unitList.Count; i++) { if (prefab.unitList[i] != null) { nameList[i] = prefab.unitList[i].unitName; //prefab.unitList[i].prefabID=i; unitIDList.Add(prefab.unitList[i].prefabID); } } EditorUnitList eUnitList = new EditorUnitList(); eUnitList.prefab = prefab; eUnitList.nameList = nameList; return(eUnitList); }
public static void LoadUnit() { GameObject obj = Resources.Load("PrefabList/UnitListPrefab", typeof(GameObject)) as GameObject; if (obj == null) { Debug.Log("load unit fail, make sure the resource file exists"); return; } UnitListPrefab prefab = obj.GetComponent <UnitListPrefab>(); unitList = prefab.unitList; for (int i = 0; i < unitList.Count; i++) { unitStats.Add(new UnitStatModifier(unitList[i])); } globalUnitStats = new UnitStatModifier(null); }
public static void LoadUnit() { GameObject obj = Resources.Load("UnitPrefabList", typeof(GameObject)) as GameObject; if (obj != null) { UnitListPrefab prefab = obj.GetComponent <UnitListPrefab>(); if (prefab != null) { //Debug.Log(prefab.unitList.Count); unitPrefabList = prefab.unitList; } } /* * Debug.Log("unitPrefabList length: "+unitPrefabList.Count); * foreach(UnitTB unit in unitPrefabList){ * if(unit==null){ * Debug.Log("null"); * } * } */ }