private void setMainCamera(ColorGradeConfig config)
    {
        UnityStandardAssets.ImageEffects.ColorGradingEffect effect = GameObject.FindObjectOfType <UnityStandardAssets.ImageEffects.ColorGradingEffect>();
        if (effect != null)
        {
            if (config != null)
            {
                effect._Shadows  = config._Shadows;
                effect._Midtones = config._Midtones;
                effect._Hilights = config._Hilights;
            }
            else
            {
                Color defaultColor = new Color(1, 1, 1, 0.5f);
                effect._Shadows  = defaultColor;
                effect._Midtones = defaultColor;
                effect._Hilights = defaultColor;
            }
        }
        System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
        EditorWindow gameview = EditorWindow.GetWindow(assembly.GetType("UnityEditor.GameView"));

        gameview.Repaint();
    }
示例#2
0
 public void applyColorGrading(ColorGradeConfig config)
 {
     this.m_TargetConfig = config;
 }
    public override void OnInspectorGUI()
    {
        ColorGradeConfig config = (ColorGradeConfig)target;

        if (this.m_ColorWheel == null)
        {
            this.m_ColorWheel = AssetDatabase.LoadAssetAtPath <Texture>("Assets/ColorGrade/Editor/colorwheel_150.png");
        }
        if (this.m_ColorWheelMarker == null)
        {
            this.m_ColorWheelMarker = AssetDatabase.LoadAssetAtPath <Texture>("Assets/ColorGrade/Editor/colorwheel_marker.png");
        }
        if (this.m_Shadow == null)
        {
            this.m_Shadow = new WheelConfig();
        }
        this.m_Shadow.setColor(config._Shadows);
        if (this.m_Midtone == null)
        {
            this.m_Midtone = new WheelConfig();
        }
        this.m_Midtone.setColor(config._Midtones);
        if (this.m_Highlight == null)
        {
            this.m_Highlight = new WheelConfig();
        }
        this.m_Highlight.setColor(config._Hilights);
        EditorGUILayout.BeginHorizontal();

        bool updated = false;

        updated |= DrawWheelHSV(this.m_Shadow);
        updated |= DrawWheelHSV(this.m_Midtone);
        updated |= DrawWheelHSV(this.m_Highlight);

        EditorGUILayout.EndHorizontal();

        if (Event.current.type == EventType.Repaint && this.m_PendingClick)
        {
            this.m_PendingClick = false;
        }

        if (
            (Event.current.button == 0) &&
            (
                Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag
            )
            )
        {
            this.m_PendingClick  = true;
            this.m_ClickPosition = Event.current.mousePosition;
            Repaint();
        }

        ColorGradeConfig wasSyncedConfig = SYNCED_CONFIG;
        bool             wasSynced       = (config == SYNCED_CONFIG);
        bool             synced          = EditorGUILayout.Toggle("Preview Main Camera", wasSynced);

        if (wasSynced != synced)
        {
            if (synced)
            {
                SYNCED_CONFIG = config;
                updated       = true;
            }
            if (!synced && wasSynced && wasSyncedConfig == config)
            {
                SYNCED_CONFIG = null;
                setMainCamera(null);
            }
        }

        if (updated)
        {
            config._Shadows  = this.m_Shadow.color;
            config._Midtones = this.m_Midtone.color;
            config._Hilights = this.m_Highlight.color;

            if (SYNCED_CONFIG == config)
            {
                setMainCamera(config);
            }
        }
    }