void LoadResourcesTable() { string resourcesTablePath = Instance.tablePathTable["ResourcesTable"]; TextAsset jsonTable = JResources.Load <TextAsset>(resourcesTablePath); ResourcesTable.LoadFromJson(jsonTable.text); }
public void Awake() { TextAsset bundleList = JResources.Load <TextAsset>(TABLE_PATH); BundlePathList tempList = JsonUtility.FromJson <BundlePathList>(bundleList.text); for (int i = 0; i < tempList.bundleList.Count; i++) { bundlePathes.Add(tempList.bundleList[i].key, tempList.bundleList[i].bundlePath); } }
void LoadTablePathTable() { TextAsset txt = JResources.Load <TextAsset>("Tables/TablePath"); string json = txt.text; TablePathTable tpt = JsonUtility.FromJson <TablePathTable>(json); for (int i = 0; i < tpt.pathTable.Count; i++) { tablePathTable.Add(tpt.pathTable[i].name, tpt.pathTable[i].path); } }
PoolData SpawnObjectToPool(string name, string path) { var obj = Instantiate(JResources.Load(path), Vector3.zero, Quaternion.identity) as GameObject; obj.SetActive(false); var list = Instance.GetPooldataList(name); PoolData newData = new PoolData(obj, true); list.Add(newData); return(newData); }
IItem CreateItem() { UnityEngine.Object obj = JResources.Load(path); GameObject instance = Instantiate(obj) as GameObject; IItem item = instance.GetComponent <IItem>(); items.Add(item); instance.transform.parent = contents; instance.transform.localScale = Vector3.one; return(item); }
public void Awake() { string localTablePath = TABLE_PATH; TextAsset ta = JResources.Load <TextAsset>(localTablePath); string localJson = ta.text; LocalizeDataList tempTable = JsonUtility.FromJson <LocalizeDataList>(localJson); int index = MapLocalizationToIndex(Application.systemLanguage); for (int i = 0; i < tempTable.List.Count; i++) { string key = tempTable.List[i].key; string value = tempTable.List[i].list[index]; LocalizeTable.AddLocalString(key, value); } }
public static void Initialize() { //find Instance all T[] objects = FindObjectsOfType <T>(); switch (objects.Length) { case 0: //it is in the resources folder? string[] typeNameSplits = typeof(T).ToString().Split('.'); string typeName = typeNameSplits[typeNameSplits.Length - 1]; UnityEngine.Object loadObj = JResources.Load("Prefabs/Singletone/" + typeName); if (null != loadObj) { GameObject go = Instantiate(loadObj) as GameObject; T obj = go.GetComponent <T>(); _instance = obj; } else { //create new gameobject Debug.LogFormat("{0} was not founded so Instnatiate {0}", typeof(T).ToString());; string[] splits = typeof(T).ToString().Split('.'); string name = splits[splits.Length - 1]; GameObject go = new GameObject(name); _instance = go.AddComponent <T>(); } break; case 1: _instance = objects[0]; break; default: Debug.LogWarningFormat("{0} is MonoSingle, so it must be unique, leave only one", typeof(T).ToString()); for (int i = 1; i < objects.Length; i++) { GameObject.Destroy(objects[i]); } _instance = objects[0]; objects = null; break; } DontDestroyOnLoad(_instance); Debug.LogFormat("{0} was set DontDestroyOnLoad object", typeof(T).ToString()); }
//#endregion void Awake() { TableLoader.Initialize(); GlobalEventQueue.Initialize(); JResources.Initialize(); EffectManager.Initialize(); OnAwake(); GlobalEventQueue.RegisterListener(DefaultEvent.LoadScene, ListenSceneChange); GlobalEventQueue.RegisterListener(DefaultEvent.AddScene, ListenAddScene); GlobalEventQueue.RegisterListener(DefaultEvent.UnloadScene, ListenUnloadScene); SceneManager.sceneLoaded += LoadedCompleteMethod; //gravity = Physics.gravity; if (null != appStartMethod) { appStartMethod.Invoke(); } }