Пример #1
0
        // --------------------------------------------------
        // BAKE

#if UNITY_EDITOR
        private IEnumerator BakePortalData()
        {
            // Generate Portal data
            m_Completion    = 0.0f;
            m_BakeTime      = 0.0f;
            m_BakeStartTime = Time.realtimeSinceStartup;
            m_BakeState     = BakeState.Occluders;
            var occluders = PortalPrepareUtil.GetOccluderData();

            m_BakeState = BakeState.Volumes;
            var volumes = PortalPrepareUtil.GetVolumeData(m_VolumeMode, m_Subdivisions);

            m_BakeState = BakeState.Visibility;
            List <VisbilityData> visibilityTable = null;

            yield return(EditorCoroutines.StartCoroutine(GenerateVisibilityTable(occluders, volumes, value => visibilityTable = value), this));

            // Serialize
            m_PortalData = new SerializablePortalData()
            {
                occluders       = occluders,
                volumes         = volumes,
                visibilityTable = visibilityTable
            };

            // Finalize
            m_BakeState  = BakeState.Active;
            m_Completion = 1.0f;
            m_BakeTime   = Time.realtimeSinceStartup - m_BakeStartTime;
            UnityEditor.SceneView.RepaintAll();
            UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
        }
Пример #2
0
        /// <summary>
        /// Cancel any active bake and clear all data. Editor only.
        /// </summary>
        public void OnClickCancel()
        {
            // Abort if in play mode as save actions arent valid
            if (Application.isPlaying)
            {
                Debug.LogWarning("Cannot modifiy Portal data while in Play mode. Aborting.");
                return;
            }

            // Reset all
            EditorCoroutines.StopAllCoroutines(this);
            m_BakeState  = BakeState.Empty;
            m_PortalData = null;
            m_Completion = 0;
            UnityEditor.SceneView.RepaintAll();
            UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
        }