コード例 #1
0
        public override void Draw(DrawInfo drawInfo)
        {
            EditorGUI.BeginChangeCheck();
            base.Draw(drawInfo);
            if (m_forceSamplerUpdate)
            {
                m_forceSamplerUpdate = false;
                m_referenceSampler   = UIUtils.GetNode(m_referenceNodeId) as TextureArrayNode;
                m_referenceArrayId   = UIUtils.GetTextureArrayNodeRegisterId(m_referenceNodeId);
            }
            if (EditorGUI.EndChangeCheck())
            {
                OnPropertyNameChanged();
            }

            bool instanced = CheckReference();

            if (m_referenceType == TexReferenceType.Instance && m_referenceSampler != null)
            {
                SetTitleText(m_referenceSampler.PropertyInspectorName + Constants.InstancePostfixStr);
                SetAdditonalTitleText(m_referenceSampler.AdditonalTitleContent.text);
            }
            else
            {
                SetTitleText(PropertyInspectorName);
                SetAdditonalTitleText(AdditonalTitleContent.text);
            }

            Rect newRect = m_remainingBox;

            newRect.width  = 110 * drawInfo.InvertedZoom;
            newRect.height = 110 * drawInfo.InvertedZoom;

            if (instanced)
            {
                if (GUI.Button(newRect, string.Empty, UIUtils.CustomStyle(CustomStyle.SamplerTextureRef)))
                {
                    UIUtils.FocusOnNode(m_referenceSampler, 1, true);
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                if (m_materialMode)
                {
                    m_materialTextureArray = ( Texture2DArray )EditorGUI.ObjectField(newRect, m_materialTextureArray, typeof(Texture2DArray), false);
                }
                else
                {
                    m_defaultTextureArray = ( Texture2DArray )EditorGUI.ObjectField(newRect, m_defaultTextureArray, typeof(Texture2DArray), false);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    SetAdditonalTitleText(string.Format(Constants.PropertyValueLabel, GetPropertyValStr()));
                    BeginDelayedDirtyProperty();
                    m_requireMaterialUpdate = true;
                }
            }
        }
コード例 #2
0
        public override void RefreshExternalReferences()
        {
            base.RefreshExternalReferences();

            m_referenceSampler = UIUtils.GetNode(m_referenceNodeId) as TextureArrayNode;
            m_referenceArrayId = UIUtils.GetTextureArrayNodeRegisterId(m_referenceNodeId);
            OnPropertyNameChanged();
        }
コード例 #3
0
        public override void DrawMainPropertyBlock()
        {
            EditorGUI.BeginChangeCheck();
            //m_referenceType = ( TexReferenceType ) EditorGUILayout.EnumPopup( Constants.ReferenceTypeStr, m_referenceType );
            m_referenceType = ( TexReferenceType )EditorGUILayoutPopup(Constants.ReferenceTypeStr, ( int )m_referenceType, Constants.ReferenceArrayLabels);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_referenceType == TexReferenceType.Object)
                {
                    UIUtils.RegisterTextureArrayNode(this);
                    UIUtils.RegisterPropertyNode(this);

                    SetTitleText(m_propertyInspectorName);
                    SetAdditonalTitleText(string.Format(Constants.PropertyValueLabel, GetPropertyValStr()));
                    m_referenceArrayId = -1;
                    m_referenceNodeId  = -1;
                    m_referenceSampler = null;
                }
                else
                {
                    UIUtils.UnregisterTextureArrayNode(this);
                    UIUtils.UnregisterPropertyNode(this);
                }
                UpdateHeaderColor();
            }

            if (m_referenceType == TexReferenceType.Object)
            {
                EditorGUI.BeginChangeCheck();
                base.DrawMainPropertyBlock();
                if (EditorGUI.EndChangeCheck())
                {
                    OnPropertyNameChanged();
                }
            }
            else
            {
                string[] arr = UIUtils.TextureArrayNodeArr();
                bool     guiEnabledBuffer = GUI.enabled;
                if (arr != null && arr.Length > 0)
                {
                    GUI.enabled = true;
                }
                else
                {
                    m_referenceArrayId = -1;
                    GUI.enabled        = false;
                }

                m_referenceArrayId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceArrayId, arr);
                GUI.enabled        = guiEnabledBuffer;

                ShowDefaults();

                DrawSamplerOptions();
            }
        }
コード例 #4
0
ファイル: TextureArrayNode.cs プロジェクト: lufvilla/shaders
        public bool CheckReference()
        {
            if (m_referenceType == TexReferenceType.Instance && m_referenceArrayId > -1)
            {
                m_referenceSampler = UIUtils.GetTextureArrayNode(m_referenceArrayId);

                if (m_referenceSampler == null)
                {
                    m_referenceArrayId = -1;
                }
            }

            return(m_referenceSampler != null);
        }
コード例 #5
0
        public bool CheckReference()
        {
            if (m_referenceType == TexReferenceType.Instance && m_referenceArrayId > -1)
            {
                m_referenceSampler = UIUtils.GetTextureArrayNode(m_referenceArrayId);

                if (m_referenceSampler == null)
                {
                    m_texPort.Locked   = false;
                    m_referenceArrayId = -1;
                }
                else
                {
                    m_texPort.Locked = true;
                }
            }
            else
            {
                m_texPort.Locked = false;
            }

            return(m_referenceSampler != null);
        }
コード例 #6
0
ファイル: TextureArrayNode.cs プロジェクト: lufvilla/shaders
        public override void Draw(DrawInfo drawInfo)
        {
            EditorGUI.BeginChangeCheck();
            base.Draw(drawInfo);
            if (m_forceSamplerUpdate)
            {
                m_forceSamplerUpdate = false;
                m_referenceSampler   = UIUtils.GetNode(m_referenceNodeId) as TextureArrayNode;
                m_referenceArrayId   = UIUtils.GetTextureArrayNodeRegisterId(m_referenceNodeId);
            }
            if (EditorGUI.EndChangeCheck())
            {
                OnPropertyNameChanged();
            }

            bool instanced = CheckReference();

            if (m_referenceType == TexReferenceType.Instance && m_referenceSampler != null)
            {
                SetTitleText(m_referenceSampler.PropertyInspectorName + Constants.InstancePostfixStr);
                SetAdditonalTitleText(m_referenceSampler.AdditonalTitleContent.text);
            }
            else
            {
                SetTitleText(PropertyInspectorName);
                SetAdditonalTitleText(AdditonalTitleContent.text);
            }

            if (m_tittleOverlayIndex == -1)
            {
                m_tittleOverlayIndex = Array.IndexOf <GUIStyle>(GUI.skin.customStyles, GUI.skin.GetStyle("ObjectFieldThumbOverlay"));
            }

            m_titleOverlay = GUI.skin.customStyles[m_tittleOverlayIndex];

            int fontSizeUpper = m_titleOverlay.fontSize;

            Rect newRect = m_globalPosition;

            newRect.width  = (128) * drawInfo.InvertedZoom;
            newRect.height = (128) * drawInfo.InvertedZoom;
            newRect.x      = m_previewRect.x;
            newRect.y      = m_previewRect.y;

            m_titleOverlay.fontSize = ( int )(9 * drawInfo.InvertedZoom);

            Rect smallButton = newRect;

            smallButton.height = 14 * drawInfo.InvertedZoom;
            smallButton.y      = newRect.yMax - smallButton.height - 2;
            smallButton.width  = 40 * drawInfo.InvertedZoom;
            smallButton.x      = newRect.xMax - smallButton.width - 2;

            m_showPreview = true;

            if (instanced)
            {
                DrawPreview(drawInfo, m_previewRect);

                if (GUI.Button(newRect, string.Empty, GUIStyle.none))
                {
                    UIUtils.FocusOnNode(m_referenceSampler, 1, true);
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();

                if (m_materialMode)
                {
                    if (m_materialTextureArray == null)
                    {
                        GUI.Box(newRect, "", UIUtils.ObjectFieldThumb);

                        Color temp = GUI.color;
                        GUI.color = Color.clear;
                        m_materialTextureArray = EditorGUIObjectField(newRect, m_materialTextureArray, typeof(Texture2DArray), false) as Texture2DArray;
                        GUI.color = temp;

                        GUI.Button(smallButton, "Select", UIUtils.GetCustomStyle(CustomStyle.SamplerButton));
                        if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2)
                        {
                            GUI.Label(newRect, "None (Texture2DArray)", UIUtils.ObjectFieldThumbOverlay);
                        }
                    }
                    else
                    {
                        Rect butRect = m_previewRect;
                        butRect.y -= 1;
                        butRect.x += 1;

                        Rect hitRect = butRect;
                        hitRect.height = 14 * drawInfo.InvertedZoom;
                        hitRect.y      = butRect.yMax - hitRect.height;
                        hitRect.width  = 4 * 14 * drawInfo.InvertedZoom;

                        Color temp = GUI.color;
                        GUI.color = Color.clear;
                        bool restoreMouse = false;
                        if (Event.current.type == EventType.MouseDown && hitRect.Contains(Event.current.mousePosition))
                        {
                            restoreMouse       = true;
                            Event.current.type = EventType.Ignore;
                        }

                        m_materialTextureArray = EditorGUIObjectField(newRect, m_materialTextureArray, typeof(Texture2DArray), false) as Texture2DArray;
                        if (restoreMouse)
                        {
                            Event.current.type = EventType.MouseDown;
                        }

                        GUI.color = temp;

                        DrawPreview(drawInfo, m_previewRect);
                        DrawPreviewMaskButtons(drawInfo, butRect);

                        GUI.Box(newRect, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerFrame));
                        GUI.Box(smallButton, "Select", UIUtils.GetCustomStyle(CustomStyle.SamplerButton));
                    }
                }
                else
                {
                    if (m_defaultTextureArray == null)
                    {
                        GUI.Box(newRect, "", UIUtils.ObjectFieldThumb);

                        Color temp = GUI.color;
                        GUI.color             = Color.clear;
                        m_defaultTextureArray = EditorGUIObjectField(newRect, m_defaultTextureArray, typeof(Texture2DArray), false) as Texture2DArray;
                        GUI.color             = temp;

                        GUI.Button(smallButton, "Select", UIUtils.GetCustomStyle(CustomStyle.SamplerButton));
                        if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2)
                        {
                            GUI.Label(newRect, "None (Texture2DArray)", UIUtils.ObjectFieldThumbOverlay);
                        }
                    }
                    else
                    {
                        Rect butRect = m_previewRect;
                        butRect.y -= 1;
                        butRect.x += 1;

                        Rect hitRect = butRect;
                        hitRect.height = 14 * drawInfo.InvertedZoom;
                        hitRect.y      = butRect.yMax - hitRect.height;
                        hitRect.width  = 4 * 14 * drawInfo.InvertedZoom;

                        Color temp = GUI.color;
                        GUI.color = Color.clear;
                        bool restoreMouse = false;
                        if (Event.current.type == EventType.MouseDown && hitRect.Contains(Event.current.mousePosition))
                        {
                            restoreMouse       = true;
                            Event.current.type = EventType.Ignore;
                        }

                        m_defaultTextureArray = EditorGUIObjectField(newRect, m_defaultTextureArray, typeof(Texture2DArray), false) as Texture2DArray;
                        if (restoreMouse)
                        {
                            Event.current.type = EventType.MouseDown;
                        }

                        GUI.color = temp;

                        DrawPreview(drawInfo, m_previewRect);
                        DrawPreviewMaskButtons(drawInfo, butRect);

                        GUI.Box(newRect, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerFrame));
                        GUI.Box(smallButton, "Select", UIUtils.GetCustomStyle(CustomStyle.SamplerButton));
                    }
                }

                //if ( m_materialMode )
                //	m_materialTextureArray = ( Texture2DArray ) EditorGUI.ObjectField( newRect, m_materialTextureArray, typeof( Texture2DArray ), false );
                //else
                //	m_defaultTextureArray = ( Texture2DArray ) EditorGUI.ObjectField( newRect, m_defaultTextureArray, typeof( Texture2DArray ), false );

                if (EditorGUI.EndChangeCheck())
                {
                    CheckTextureImporter(true);
                    SetAdditonalTitleText(string.Format(Constants.PropertyValueLabel, GetPropertyValStr()));
                    BeginDelayedDirtyProperty();
                    m_requireMaterialUpdate = true;
                }

                m_titleOverlay.fontSize = fontSizeUpper;
            }
        }