Esempio n. 1
0
    void Awake()
    {
        if (EditorApplication.isPlaying)
        {
            Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;


            AssetBundle.UnloadAllAssetBundles(true);

            ResourceManager.Reset();
            ResourceManager.SetAssetGetPathCallback(null);


            AssetBundle gameBundle = null;

            ResourceManager.AddBundle("resources", new ResourcesBundle());

            LoadBundles(Application.streamingAssetsPath);

            var gdir = PlayerPrefs.GetString("GAME_CONTENT_DIR", "");
            LoadBundles(gdir);

            foreach (var f in AssetBundle.GetAllLoadedAssetBundles())
            {
                if (f != null)
                {
                    //ResourceManager.AddBundle(f.name, f);

                    if (f.name.IndexOf("editor") >= 0) //TODO
                    {
                        gameBundle = f;
                    }
                }
            }

            GameObject game = gameBundle.LoadAsset <GameObject>("Game");
            Instantiate(game);

            GameStorage.SetInt("PostImageEffects", 0);

            HBAOPlus.useHBOAPlus = false;

            if (spawnScene.Length > 0)
            {
                SpawnScene();
            }

            //fallback replace detect
            foreach (var obj in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects())
            {
                foreach (EntityComponent r in obj.GetComponentsInChildren <EntityComponent>())
                {
                    if (!IsValidEntityObject(r.gameObject))
                    {
                        if (r.Entity == null)
                        {
                            Debug.LogError("PIE Error [Entity is null]" + r.name);
                            continue;
                        }
                        else if (r.Entity.Prototype == null)
                        {
                            Debug.LogError("PIE Error [Prototype is null]" + r.name);
                            continue;
                        }
                        else if (r.Entity.Prototype.Prefab == null)
                        {
                            Debug.LogError("PIE Error [Prefab is null]" + r.name);
                            continue;
                        }

                        var prefab = r.Entity.Prototype.Prefab;

                        var copy = Instantiate <GameObject>(r.Entity.Prototype.Prefab, r.gameObject.transform.position, r.gameObject.transform.rotation);
                        copy.transform.localScale = r.transform.lossyScale;
                        copy.name = r.name;

                        copy.GetComponent <EntityComponent>().SetEntity(r.Entity);
                        r.gameObject.SetActive(false);
                        r.gameObject.name += "_temp";
                    }
                }
            }

            if (_sunTestLight != null)
            {
                _sunTestLight.gameObject.SetActive(false);
            }
        }
        else
        {
        }
    }