Пример #1
0
        public void Initialize(Camera Camera, DynamicDecals System)
        {
            //Register it to our rendering path
            InitializeRenderingMethod(Camera);

            //Enable
            initialized = true;
        }
Пример #2
0
        public void UpdateRenderingMethod(Camera Camera, DynamicDecals System)
        {
            //Determine our rendering method
            if (replacement != System.Settings.shaderReplacement)
            {
                //Update our rendering method
                replacement = System.Settings.shaderReplacement;

                //Add ourself to the new rendering method
                InitializeRenderingMethod(Camera);
            }
        }
Пример #3
0
        private void OnGUI()
        {
            //Grab our settings
            DynamicDecalSettings settings = DynamicDecals.System.Settings;

            //Calculate required rect height
            float maskHeight  = 120;
            float debugHeight = (Application.isPlaying) ? 360 : 80;
            float totalHeight = LlockhamEditorUtility.TabHeight * (settings.pools.Length + 4) + maskHeight + debugHeight + 54;

            //Begin change check & scrollView
            EditorGUI.BeginChangeCheck();
            Rect scrollRect = new Rect(0, 0, position.width - 20, totalHeight);

            scrollPosition = GUI.BeginScrollView(new Rect(10, 10, position.width - 20, position.height - 20), scrollPosition, scrollRect, GUIStyle.none, GUIStyle.none);

            //Mask settings
            MaskSettings(new Rect(0, 44 + (LlockhamEditorUtility.TabHeight * (settings.pools.Length + 4)), scrollRect.width, maskHeight), settings);

            //Pool settings
            PoolHeader(new Rect(0, 10, scrollRect.width, 24), settings);
            QualityTabs(new Rect(0, 34, scrollRect.width, LlockhamEditorUtility.TabHeight));
            PoolSettings(new Rect(0, 34 + LlockhamEditorUtility.TabHeight, scrollRect.width, LlockhamEditorUtility.TabHeight * (settings.pools.Length + 3)), settings);

            //Debug settings
            DebugSettings(new Rect(0, 54 + (LlockhamEditorUtility.TabHeight * (settings.pools.Length + 4)) + maskHeight, scrollRect.width, debugHeight));

            //End change check & scrollView
            GUI.EndScrollView();
            if (EditorGUI.EndChangeCheck())
            {
                //If the asset already exists, mark it to be saved
                if (Resources.Load <DynamicDecalSettings>("Settings") != null)
                {
                    EditorUtility.SetDirty(settings);
                }

                //If the asset doen't exist, create it
                else
                {
                    AssetDatabase.CreateAsset(settings, assetPath);
                }

                //Apply changes to system immediately
                DynamicDecals.ApplySettings();
            }
        }
Пример #4
0
        private void UndoRedo()
        {
            //Grab our settings
            DynamicDecalSettings settings = DynamicDecals.System.Settings;

            //Recalculate passes
            settings.CalculatePasses();

            //Update renderers
            DynamicDecals.System.UpdateRenderers();

            //Repaint the window to show changes immediately
            Repaint();

            //Apply changes to system immediately
            DynamicDecals.ApplySettings();
        }
Пример #5
0
        public void UpdateRenderingMethod(Camera Camera, DynamicDecals System)
        {
            //Use standard shader replacement by default
            ShaderReplacement shaderReplacement = ShaderReplacement.SinglePass;

            //If we can't render to at least 3 render textures perform shade replacement in 2 passes
            if (SystemInfo.supportedRenderTargetCount < 3)
            {
                shaderReplacement = ShaderReplacement.DoublePass;
            }

            //Android / Mac bug with single pass replacement
            #if (UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX || UNITY_ANDROID)
            shaderReplacement = ShaderReplacement.DoublePass;
            #endif

            //If rendering a VR eye, use VR replacement
            if (UnityEngine.XR.XRSettings.enabled && Camera.stereoTargetEye != StereoTargetEyeMask.None)
            {
                shaderReplacement = ShaderReplacement.TriplePass;
            }

            //If on old device, use mobile replacement
            if (SystemInfo.graphicsShaderLevel <= 20 || SystemInfo.supportedRenderTargetCount < 2)
            {
                shaderReplacement = ShaderReplacement.Classic;
            }

            //Determine our rendering method
            if (replacement != shaderReplacement)
            {
                //Update our rendering method
                replacement = shaderReplacement;

                //Add ourself to the new rendering method
                InitializeRenderingMethod(Camera);
            }
        }
Пример #6
0
        private void OnEnable()
        {
            //Singleton
            if (system == null)
            {
                system = this;
            }
            else if (system != this)
            {
                if (Application.isPlaying)
                {
                    Destroy(gameObject);
                }
                else
                {
                    DestroyImmediate(gameObject, true);
                }
                return;
            }

            //Initialize the system
            Initialize();
        }