コード例 #1
0
    public void ReloadScriptables()
    {
        foreach (Scriptable s in scriptables)
        {
            Object.Destroy(s);
        }
        scriptables.Clear();
        WorldGenerator worldGenerator = GameObject.Find("WorldGenerator").GetComponent <WorldGenerator>();

        scriptables = new List <Scriptable>();
        GameObject scriptable;

        if (scriptablesInfo.ContainsKey(worldGenerator.world_id))
        {
            foreach (ScriptableInfo s in scriptablesInfo[worldGenerator.world_id])
            {
                //all scriptables must implement "Scriptable"
                string pathname = "Scriptables/" + s.prefabName;
                scriptable = (GameObject)Instantiate((GameObject)Resources.Load(pathname));
                Scriptable script = scriptable.GetComponent <Scriptable>();
                script.Load(this, s);
                scriptables.Add(scriptable.GetComponent <Scriptable>());
            }
        }
    }