Ejemplo n.º 1
0
        public void BakeAndSaveData(int layerMask, int camoMask)
        {
            EditorUtility.DisplayProgressBar("FOW", "Baking fog of war. Please wait...", 0);

            FOWData data = Bake(layerMask, camoMask);

            if (data != null)
            {
                EditorUtility.DisplayProgressBar("FOW", "Saving the data...", 1);

                IDataOut persister = new PersistenceWriter(info.filePath);
                data.Serialize(persister);
                persister.Close();
            }

            EditorUtility.ClearProgressBar();
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            string             scene = gameObject.scene.name;
            FOWLevelBakingInfo info  = Resources.Load <FOWLevelBakingInfo>("BakingInfo/" + scene);

            if (info == null)
            {
                Debug.LogError("FOW view couldn't be initialized (Missing baking info)");
                Destroy(gameObject);
                return;
            }

            TextAsset asset = Resources.Load <TextAsset>(info.resourcePath);

            if (asset == null)
            {
                Debug.LogError("FOW view couldn't be initialized (Missing data: " + info.filePath);
                Destroy(gameObject);
                return;
            }

            PersistenceReader reader = new PersistenceReader(asset.bytes);

            data = FOWData.DeSerialize(reader);

            Debug.Log("FOW data loaded!");

            agentViews     = new Dictionary <IFOWAgent, AgentInfo>();
            addRemoveQueue = new Queue <Pair <IFOWAgent, bool> >();

            SetupMaterials();
            SetupTransforms(info);

            lastColor  = fogColor;
            lastFilter = filterMode;

            updater = new ColorArrayUpdateWorker(agentViews, data, data.LengthInTiles);
            updater.Start();

            StartCoroutine(UpdateRoutine());
            instance = this;
            ShowFog(false);
        }