Exemple #1
0
        public override void OnNodeLayout(DrawInfo drawInfo)
        {
            if (m_firstDraw)
            {
                m_firstDraw = false;
                AfterCommonInit();
                OnNodeChange();
            }

            if (m_forceVisualDataUpdate)
            {
                m_forceVisualDataUpdate = false;
                m_visualDataType        = GetLastInputDataTypeRecursively();
            }

            if (m_repopulateDictionaries)
            {
                m_repopulateDictionaries = false;

                m_inputPortsDict.Clear();
                int inputCount = m_inputPorts.Count;
                for (int i = 0; i < inputCount; i++)
                {
                    m_inputPortsDict.Add(m_inputPorts[i].PortId, m_inputPorts[i]);
                }

                m_outputPortsDict.Clear();
                int outputCount = m_outputPorts.Count;
                for (int i = 0; i < outputCount; i++)
                {
                    m_outputPortsDict.Add(m_outputPorts[i].PortId, m_outputPorts[i]);
                }
            }

            if (m_sizeIsDirty)
            {
                m_sizeIsDirty = false;
                m_extraSize.Set(20f, 20f);
                m_position.width  = m_extraSize.x + UIUtils.PortsSize.x;
                m_position.height = m_extraSize.y + UIUtils.PortsSize.y;

                Vec2Position -= Position.size * 0.5f;
                if (OnNodeChangeSizeEvent != null)
                {
                    OnNodeChangeSizeEvent(this);
                }

                ChangeSizeFinished();
                //ChangeSize();
            }

            CalculatePositionAndVisibility(drawInfo);

            // Input Ports
            {
                m_currInputPortPos          = m_globalPosition;
                m_currInputPortPos.width    = drawInfo.InvertedZoom * UIUtils.PortsSize.x;
                m_currInputPortPos.height   = drawInfo.InvertedZoom * UIUtils.PortsSize.y;
                m_currInputPortPos.position = m_globalPosition.center - m_currInputPortPos.size * 0.5f;
                int inputCount = m_inputPorts.Count;

                for (int i = 0; i < inputCount; i++)
                {
                    if (m_inputPorts[i].Visible)
                    {
                        // Button
                        m_inputPorts[i].Position = m_currInputPortPos;

                        if (!m_inputPorts[i].Locked)
                        {
                            float overflow       = 2;
                            float scaledOverflow = 3 * drawInfo.InvertedZoom;
                            m_auxRect       = m_currInputPortPos;
                            m_auxRect.yMin -= scaledOverflow + overflow;
                            m_auxRect.yMax += scaledOverflow + overflow;
                            m_auxRect.xMin -= Constants.PORT_INITIAL_X * drawInfo.InvertedZoom + scaledOverflow + overflow;
                            m_auxRect.xMax += m_inputPorts[i].LabelSize.x + Constants.PORT_TO_LABEL_SPACE_X * drawInfo.InvertedZoom + scaledOverflow + overflow;
                            m_inputPorts[i].ActivePortArea = m_auxRect;
                        }
                        m_currInputPortPos.y += drawInfo.InvertedZoom * (m_fontHeight + Constants.INPUT_PORT_DELTA_Y);
                    }
                }
            }

            // Output Ports
            {
                m_currOutputPortPos          = m_globalPosition;
                m_currOutputPortPos.width    = drawInfo.InvertedZoom * UIUtils.PortsSize.x;
                m_currOutputPortPos.height   = drawInfo.InvertedZoom * UIUtils.PortsSize.y;
                m_currOutputPortPos.position = m_globalPosition.center - m_currOutputPortPos.size * 0.5f;
                //m_currOutputPortPos.x += ( m_globalPosition.width - drawInfo.InvertedZoom * ( Constants.PORT_INITIAL_X + m_anchorAdjust ) );
                //m_currOutputPortPos.y += drawInfo.InvertedZoom * Constants.PORT_INITIAL_Y;// + m_extraHeaderHeight * drawInfo.InvertedZoom;
                int outputCount = m_outputPorts.Count;

                for (int i = 0; i < outputCount; i++)
                {
                    if (m_outputPorts[i].Visible)
                    {
                        //Button
                        m_outputPorts[i].Position = m_currOutputPortPos;

                        if (!m_outputPorts[i].Locked)
                        {
                            float overflow       = 2;
                            float scaledOverflow = 3 * drawInfo.InvertedZoom;
                            m_auxRect       = m_currOutputPortPos;
                            m_auxRect.yMin -= scaledOverflow + overflow;
                            m_auxRect.yMax += scaledOverflow + overflow;
                            m_auxRect.xMin -= m_outputPorts[i].LabelSize.x + Constants.PORT_TO_LABEL_SPACE_X * drawInfo.InvertedZoom + scaledOverflow + overflow;
                            m_auxRect.xMax += Constants.PORT_INITIAL_X * drawInfo.InvertedZoom + scaledOverflow + overflow;
                            m_outputPorts[i].ActivePortArea = m_auxRect;
                        }
                        m_currOutputPortPos.y += drawInfo.InvertedZoom * (m_fontHeight + Constants.INPUT_PORT_DELTA_Y);
                    }
                }
            }
        }
Exemple #2
0
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);
            if (m_previewNode)
            {
                m_additionalContent.text = "Preview";
            }
            else
            {
                m_additionalContent.text = "";
            }

            if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3)
            {
                if (!m_isEditing && ((!ContainerGraph.ParentWindow.MouseInteracted && drawInfo.CurrentEventType == EventType.MouseDown && m_titleClickArea.Contains(drawInfo.MousePosition))))
                {
                    if ((EditorApplication.timeSinceStartup - m_clickTime) < m_doubleClickTime)
                    {
                        m_startEditing = true;
                    }
                    else
                    {
                        GUI.FocusControl(null);
                    }
                    m_clickTime = EditorApplication.timeSinceStartup;
                }
                else if (m_isEditing && ((drawInfo.CurrentEventType == EventType.MouseDown && !m_titleClickArea.Contains(drawInfo.MousePosition)) || !EditorGUIUtility.editingTextField))
                {
                    m_stopEditing = true;
                }

                if (m_isEditing || m_startEditing)
                {
                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName(m_uniqueName);
                    m_outputName = EditorGUITextField(m_titleClickArea, string.Empty, m_outputName, UIUtils.GetCustomStyle(CustomStyle.NodeTitle));
                    if (EditorGUI.EndChangeCheck())
                    {
                        SetTitleText(m_outputName);
                        UIUtils.UpdateFunctionInputData(UniqueId, m_outputName);
                    }

                    if (m_startEditing)
                    {
                        EditorGUI.FocusTextInControl(m_uniqueName);
                    }
                }

                if (drawInfo.CurrentEventType == EventType.Repaint)
                {
                    if (m_startEditing)
                    {
                        m_startEditing = false;
                        m_isEditing    = true;
                    }

                    if (m_stopEditing)
                    {
                        m_stopEditing = false;
                        m_isEditing   = false;
                        GUI.FocusControl(null);
                    }
                }
            }
        }
Exemple #3
0
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);

            if (!m_isVisible)
            {
                return;
            }

            if (m_isEditingFields && m_currentParameterType != PropertyType.Global)
            {
                bool      currMode = m_materialMode && m_currentParameterType != PropertyType.Constant;
                Matrix4x4 value    = currMode ? m_materialValue : m_defaultValue;

                EditorGUI.BeginChangeCheck();
                for (int row = 0; row < 3; row++)
                {
                    for (int column = 0; column < 3; column++)
                    {
                        m_propertyDrawPos.position = m_remainingBox.position + Vector2.Scale(m_propertyDrawPos.size, new Vector2(column, row)) + new Vector2(Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row);
                        value[row, column]         = EditorGUIFloatField(m_propertyDrawPos, string.Empty, value[row, column], UIUtils.MainSkin.textField);
                    }
                }

                if (currMode)
                {
                    m_materialValue = value;
                }
                else
                {
                    m_defaultValue = value;
                }

                if (EditorGUI.EndChangeCheck())
                {
                    m_requireMaterialUpdate = m_materialMode;
                    BeginDelayedDirtyProperty();
                }
            }
            else if (drawInfo.CurrentEventType == EventType.Repaint)
            {
                bool guiEnabled = GUI.enabled;
                GUI.enabled = m_currentParameterType != PropertyType.Global;

                bool      currMode = m_materialMode && m_currentParameterType != PropertyType.Constant;
                Matrix4x4 value    = currMode ? m_materialValue : m_defaultValue;
                for (int row = 0; row < 3; row++)
                {
                    for (int column = 0; column < 3; column++)
                    {
                        Rect fakeField = m_propertyDrawPos;
                        fakeField.position = m_remainingBox.position + Vector2.Scale(m_propertyDrawPos.size, new Vector2(column, row)) + new Vector2(Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * column, Constants.FLOAT_WIDTH_SPACING * drawInfo.InvertedZoom * row);
                        if (GUI.enabled)
                        {
                            EditorGUIUtility.AddCursorRect(fakeField, MouseCursor.Text);
                        }

                        if (m_previousValue[row, column] != value[row, column])
                        {
                            m_previousValue[row, column] = value[row, column];
                            m_fieldText[row, column]     = value[row, column].ToString();
                        }

                        GUI.Label(fakeField, m_fieldText[row, column], UIUtils.MainSkin.textField);
                    }
                }
                GUI.enabled = guiEnabled;
            }
        }
 public override void OnNodeLogicUpdate(DrawInfo drawInfo)
 {
     base.OnNodeLogicUpdate(drawInfo);
     CheckReference();
 }
Exemple #5
0
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);

            if (m_isEditingPicker && m_drawPicker)
            {
                Rect hitRect = m_previewRect;
                hitRect.height = 14 * drawInfo.InvertedZoom;
                hitRect.y      = m_previewRect.yMax - hitRect.height;
                hitRect.width  = 4 * 14 * drawInfo.InvertedZoom;

                bool restoreMouse = false;
                if (Event.current.type == EventType.MouseDown && hitRect.Contains(drawInfo.MousePosition))
                {
                    restoreMouse       = true;
                    Event.current.type = EventType.Ignore;
                }

                EditorGUI.BeginChangeCheck();
                m_colorBuffer = GUI.color;
                GUI.color     = Color.clear;
                if (m_materialMode)
                {
                    m_materialTextureArray = EditorGUIObjectField(m_previewRect, m_materialTextureArray, typeof(Texture2DArray), false) as Texture2DArray;
                }
                else
                {
                    m_defaultTextureArray = EditorGUIObjectField(m_previewRect, m_defaultTextureArray, typeof(Texture2DArray), false) as Texture2DArray;
                }
                GUI.color = m_colorBuffer;

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

                if (restoreMouse)
                {
                    Event.current.type = EventType.MouseDown;
                }

                if ((drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp))
                {
                    DrawPreviewMaskButtonsLayout(drawInfo, m_previewRect);
                }
            }

            if (drawInfo.CurrentEventType != EventType.Repaint)
            {
                return;
            }

            switch (m_state)
            {
            default:
            case ReferenceState.Self:
                if (drawInfo.CurrentEventType == EventType.Repaint)
                {
                    m_drawPreview = false;
                    m_drawPicker  = true;

                    DrawTexturePicker(drawInfo);
                }
                break;

            case ReferenceState.Connected:
                if (drawInfo.CurrentEventType == EventType.Repaint)
                {
                    m_drawPreview = true;
                    m_drawPicker  = false;

                    if (m_previewTextProp != null)
                    {
                        SetTitleTextOnCallback(m_previewTextProp.TitleContent.text, (instance, newTitle) => instance.TitleContent.text = newTitle + " (Input)");
                        SetAdditonalTitleText(m_previewTextProp.AdditonalTitleContent.text);
                    }

                    // Draw chain lock
                    GUI.Label(m_iconPos, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerTextureIcon));

                    // Draw frame around preview
                    GUI.Label(m_previewRect, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerFrame));
                }
                break;

            case ReferenceState.Instance:
            {
                m_drawPreview = true;
                m_drawPicker  = false;

                if (m_referenceSampler != null)
                {
                    SetTitleTextOnCallback(m_referenceSampler.PreviewTextProp.TitleContent.text, (instance, newTitle) => instance.TitleContent.text = newTitle + Constants.InstancePostfixStr);
                    SetAdditonalTitleText(m_referenceSampler.PreviewTextProp.AdditonalTitleContent.text);
                }

                // Draw chain lock
                GUI.Label(m_iconPos, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerTextureIcon));

                // Draw frame around preview
                GUI.Label(m_previewRect, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerFrame));
            }
            break;
            }
        }
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);

            if (m_editing)
            {
                m_textures = m_proceduralMaterial != null?m_proceduralMaterial.GetGeneratedTextures() : null;

                if (GUI.Button(m_pickerArea, string.Empty, GUIStyle.none))
                {
                    int controlID = EditorGUIUtility.GetControlID(FocusType.Passive);
                    EditorGUIUtility.ShowObjectPicker <ProceduralMaterial>(m_proceduralMaterial, false, "", controlID);
                }

                string             commandName = Event.current.commandName;
                UnityEngine.Object newValue    = null;
                if (commandName == "ObjectSelectorUpdated")
                {
                    newValue = EditorGUIUtility.GetObjectPickerObject();
                    if (newValue != (UnityEngine.Object)m_proceduralMaterial)
                    {
                        UndoRecordObject(this, "Changing value EditorGUIObjectField on node Substance Sample");

                        m_proceduralMaterial = newValue != null ? (ProceduralMaterial)newValue : null;
                        m_textures           = m_proceduralMaterial != null?m_proceduralMaterial.GetGeneratedTextures() : null;

                        OnNewSubstanceSelected(m_textures);
                    }
                }
                else if (commandName == "ObjectSelectorClosed")
                {
                    newValue = EditorGUIUtility.GetObjectPickerObject();
                    if (newValue != (UnityEngine.Object)m_proceduralMaterial)
                    {
                        UndoRecordObject(this, "Changing value EditorGUIObjectField on node Substance Sample");

                        m_proceduralMaterial = newValue != null ? (ProceduralMaterial)newValue : null;
                        m_textures           = m_proceduralMaterial != null?m_proceduralMaterial.GetGeneratedTextures() : null;

                        OnNewSubstanceSelected(m_textures);
                    }
                    m_editing = false;
                }

                if (GUI.Button(m_previewArea, string.Empty, GUIStyle.none))
                {
                    if (m_proceduralMaterial != null)
                    {
                        Selection.activeObject = m_proceduralMaterial;
                        EditorGUIUtility.PingObject(Selection.activeObject);
                    }
                    m_editing = false;
                }
            }

            if (drawInfo.CurrentEventType == EventType.Repaint)
            {
                if (!m_editing)
                {
                    m_textures = m_proceduralMaterial != null?m_proceduralMaterial.GetGeneratedTextures() : null;
                }

                if (m_textures != null)
                {
                    if (m_firstOutputConnected < 0)
                    {
                        CalculateFirstOutputConnected();
                    }
                    else if (m_textures.Length != m_textureTypes.Length)
                    {
                        OnNewSubstanceSelected(m_textures);
                    }

                    int  texCount    = m_outputConns.Count;
                    Rect individuals = m_previewArea;
                    individuals.height /= texCount;

                    for (int i = 0; i < texCount; i++)
                    {
                        EditorGUI.DrawPreviewTexture(individuals, m_textures[m_outputConns[i]], null, ScaleMode.ScaleAndCrop);
                        individuals.y += individuals.height;
                    }
                }
                else
                {
                    GUI.Label(m_previewArea, string.Empty, UIUtils.ObjectFieldThumb);
                }

                if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2)
                {
                    Rect smallButton = m_previewArea;
                    smallButton.height = 14 * drawInfo.InvertedZoom;
                    smallButton.y      = m_previewArea.yMax - smallButton.height - 2;
                    smallButton.width  = 40 * drawInfo.InvertedZoom;
                    smallButton.x      = m_previewArea.xMax - smallButton.width - 2;
                    if (m_textures == null)
                    {
                        GUI.Label(m_previewArea, "None (Procedural Material)", UIUtils.ObjectFieldThumbOverlay);
                    }
                    GUI.Label(m_pickerArea, "Select", UIUtils.GetCustomStyle(CustomStyle.SamplerButton));
                }

                GUI.Label(m_previewArea, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerFrame));
            }
        }
Exemple #7
0
        public override void OnNodeLayout(DrawInfo drawInfo)
        {
            if (m_nodesIds.Count > 0)
            {
                for (int i = 0; i < m_nodesIds.Count; i++)
                {
                    ParentNode node = ContainerGraph.GetNode(m_nodesIds[i]);
                    if (node)
                    {
                        AddNodeToCommentary(node);
                    }
                }
                m_nodesIds.Clear();
            }

            if (m_reRegisterNodes)
            {
                m_reRegisterNodes = false;
                m_nodesOnCommentaryDict.Clear();
                for (int i = 0; i < m_nodesOnCommentary.Count; i++)
                {
                    if (m_nodesOnCommentary[i] != null)
                    {
                        m_nodesOnCommentary[i].OnNodeStoppedMovingEvent += NodeStoppedMoving;
                        m_nodesOnCommentary[i].OnNodeDestroyedEvent     += NodeDestroyed;
                        m_nodesOnCommentaryDict.Add(m_nodesOnCommentary[i].UniqueId, m_nodesOnCommentary[i]);
                    }
                }
            }

            //base.OnLayout( drawInfo );
            CalculatePositionAndVisibility(drawInfo);

            m_headerPosition        = m_globalPosition;
            m_headerPosition.height = UIUtils.CurrentHeaderHeight;

            m_auxHeaderPos        = m_position;
            m_auxHeaderPos.height = UIUtils.HeaderMaxHeight;

            m_commentArea        = m_globalPosition;
            m_commentArea.height = COMMENTARY_BOX_HEIGHT * drawInfo.InvertedZoom;
            m_commentArea.xMin  += 10 * drawInfo.InvertedZoom;
            m_commentArea.xMax  -= 10 * drawInfo.InvertedZoom;

            if (m_resizeIconTex == null)
            {
                m_resizeIconTex = UIUtils.GetCustomStyle(CustomStyle.CommentaryResizeButton).normal.background;
            }

            // LEFT RESIZE BUTTON
            m_resizeLeftIconCoords        = m_globalPosition;
            m_resizeLeftIconCoords.x      = m_globalPosition.x + 2;
            m_resizeLeftIconCoords.y      = m_globalPosition.y + m_globalPosition.height - 2 - (m_resizeIconTex.height + ResizeButtonPos.y) * drawInfo.InvertedZoom;
            m_resizeLeftIconCoords.width  = m_resizeIconTex.width * drawInfo.InvertedZoom;
            m_resizeLeftIconCoords.height = m_resizeIconTex.height * drawInfo.InvertedZoom;

            // RIGHT RESIZE BUTTON
            m_resizeRightIconCoords        = m_globalPosition;
            m_resizeRightIconCoords.x      = m_globalPosition.x + m_globalPosition.width - 1 - (m_resizeIconTex.width + ResizeButtonPos.x) * drawInfo.InvertedZoom;
            m_resizeRightIconCoords.y      = m_globalPosition.y + m_globalPosition.height - 2 - (m_resizeIconTex.height + ResizeButtonPos.y) * drawInfo.InvertedZoom;
            m_resizeRightIconCoords.width  = m_resizeIconTex.width * drawInfo.InvertedZoom;
            m_resizeRightIconCoords.height = m_resizeIconTex.height * drawInfo.InvertedZoom;
        }
Exemple #8
0
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);

            if (!m_isVisible)
            {
                return;
            }

            if (m_isEditingFields && m_currentParameterType != PropertyType.Global)
            {
                float labelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = LabelWidth * drawInfo.InvertedZoom;

                if (m_materialMode && m_currentParameterType != PropertyType.Constant)
                {
                    EditorGUI.BeginChangeCheck();
                    m_materialValue = EditorGUIIntField(m_propertyDrawPos, "  ", m_materialValue, UIUtils.MainSkin.textField);
                    if (EditorGUI.EndChangeCheck())
                    {
                        PreviewIsDirty          = true;
                        m_requireMaterialUpdate = true;
                        if (m_currentParameterType != PropertyType.Constant)
                        {
                            BeginDelayedDirtyProperty();
                        }
                    }
                }
                else
                {
                    EditorGUI.BeginChangeCheck();

                    m_defaultValue = EditorGUIIntField(m_propertyDrawPos, "  ", m_defaultValue, UIUtils.MainSkin.textField);

                    if (EditorGUI.EndChangeCheck())
                    {
                        PreviewIsDirty = true;
                        BeginDelayedDirtyProperty();
                    }
                }
                EditorGUIUtility.labelWidth = labelWidth;
            }
            else if (drawInfo.CurrentEventType == EventType.Repaint)
            {
                bool guiEnabled = GUI.enabled;
                GUI.enabled = m_currentParameterType != PropertyType.Global;
                Rect fakeField = m_propertyDrawPos;
                fakeField.xMin += LabelWidth * drawInfo.InvertedZoom;
                if (GUI.enabled)
                {
                    Rect fakeLabel = m_propertyDrawPos;
                    fakeLabel.xMax = fakeField.xMin;
                    EditorGUIUtility.AddCursorRect(fakeLabel, MouseCursor.SlideArrow);
                    EditorGUIUtility.AddCursorRect(fakeField, MouseCursor.Text);
                }
                bool currMode = m_materialMode && m_currentParameterType != PropertyType.Constant;
                int  value    = currMode ? m_materialValue : m_defaultValue;

                if (m_previousValue != value)
                {
                    m_previousValue = value;
                    m_fieldText     = value.ToString();
                }

                GUI.Label(fakeField, m_fieldText, UIUtils.MainSkin.textField);
                GUI.enabled = guiEnabled;
            }
        }
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);

            // Custom Editable Title
            if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3)
            {
                if (!m_isEditing && ((!ContainerGraph.ParentWindow.MouseInteracted && drawInfo.CurrentEventType == EventType.MouseDown && m_titleClickArea.Contains(drawInfo.MousePosition))))
                {
                    if ((EditorApplication.timeSinceStartup - m_clickTime) < m_doubleClickTime)
                    {
                        m_startEditing = true;
                    }
                    else
                    {
                        GUI.FocusControl(null);
                    }
                    m_clickTime = EditorApplication.timeSinceStartup;
                }
                else if (m_isEditing && ((drawInfo.CurrentEventType == EventType.MouseDown && !m_titleClickArea.Contains(drawInfo.MousePosition)) || !EditorGUIUtility.editingTextField))
                {
                    m_stopEditing = true;
                }

                if (m_isEditing || m_startEditing)
                {
                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName(m_uniqueName);
                    m_propertyInspectorName = EditorGUITextField(m_titleClickArea, string.Empty, m_propertyInspectorName, UIUtils.GetCustomStyle(CustomStyle.NodeTitle));
                    if (EditorGUI.EndChangeCheck())
                    {
                        SetTitleText(m_propertyInspectorName);
                        m_sizeIsDirty = true;
                        m_isDirty     = true;
                        if (m_propertyInspectorName.Length > 0)
                        {
                            BeginPropertyFromInspectorCheck();
                        }
                    }

                    if (m_startEditing)
                    {
                        EditorGUI.FocusTextInControl(m_uniqueName);
                    }
                    //if( m_stopEditing )
                    //	GUI.FocusControl( null );
                }

                if (drawInfo.CurrentEventType == EventType.Repaint)
                {
                    if (m_startEditing)
                    {
                        m_startEditing = false;
                        m_isEditing    = true;
                    }

                    if (m_stopEditing)
                    {
                        m_stopEditing = false;
                        m_isEditing   = false;
                        GUI.FocusControl(null);
                    }
                }


                if (m_freeType)
                {
                    if (m_dropdownEditing)
                    {
                        PropertyType parameterType = ( PropertyType )EditorGUIEnumPopup(m_dropdownRect, m_currentParameterType, UIUtils.PropertyPopUp);
                        if (parameterType != m_currentParameterType)
                        {
                            ChangeParameterType(parameterType);
                            BeginPropertyFromInspectorCheck();
                            m_dropdownEditing = false;
                        }
                    }
                }
            }
        }
Exemple #10
0
 public override void OnNodeLayout(DrawInfo drawInfo)
 {
     base.OnNodeLayout(drawInfo);
     m_upperLeftWidget.OnNodeLayout(m_globalPosition, drawInfo);
 }
Exemple #11
0
 public override void DrawGUIControls(DrawInfo drawInfo)
 {
     base.DrawGUIControls(drawInfo);
     m_upperLeftWidget.DrawGUIControls(drawInfo);
 }
 public override void Draw(DrawInfo drawInfo)
 {
     base.Draw(drawInfo);
     CheckReference();
 }
Exemple #13
0
 public override void DrawGUIControls(DrawInfo drawInfo)
 {
     //base.DrawGUIControls( drawInfo );
 }
Exemple #14
0
        public override void OnNodeRepaint(DrawInfo drawInfo)
        {
            //base.OnRepaint( drawInfo );
            //return;
            if (!m_isVisible)
            {
                return;
            }

            m_colorBuffer = GUI.color;

            // Output Ports
            int      outputCount     = m_outputPorts.Count;
            GUIStyle outputPortStyle = UIUtils.GetCustomStyle(CustomStyle.OutputPortLabel);

            for (int i = 0; i < outputCount; i++)
            {
                if (m_outputPorts[i].Visible)
                {
                    // Output Port Icon
                    if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4)
                    {
                        if (m_outputPorts[i].Locked)
                        {
                            GUI.color = Constants.LockedPortColor;
                        }
                        else if (ContainerGraph.ParentWindow.Options.ColoredPorts)
                        {
                            GUI.color = UIUtils.GetColorForDataType(m_visualDataType, false, false);
                        }
                        else
                        {
                            GUI.color = m_outputPorts[i].HasCustomColor ? m_outputPorts[i].CustomColor : UIUtils.GetColorForDataType(m_visualDataType, true, false);
                        }

                        GUIStyle style = m_outputPorts[i].IsConnected ? UIUtils.GetCustomStyle(CustomStyle.PortFullIcon) : UIUtils.GetCustomStyle(CustomStyle.PortEmptyIcon);
                        GUI.Label(m_outputPorts[i].Position, string.Empty, style);

                        GUI.color = m_colorBuffer;
                    }

                    // Output Port Label
                    if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3)
                    {
                        if (m_outputPorts[i].Locked)
                        {
                            GUI.color = Constants.PortLockedTextColor;
                            GUI.Label(m_outputPorts[i].LabelPosition, m_outputPorts[i].Name, outputPortStyle);
                            GUI.color = m_colorBuffer;
                        }
                        else
                        {
                            GUI.Label(m_outputPorts[i].LabelPosition, m_outputPorts[i].Name, outputPortStyle);
                        }
                    }
                }
            }

            // Selection Box
            if (m_selected)
            {
                Rect selectionBox = m_globalPosition;
                selectionBox.size   = Vector2.one * 16 * drawInfo.InvertedZoom + Vector2.one * 4;
                selectionBox.center = m_globalPosition.center;
                GUI.DrawTexture(selectionBox, UIUtils.WireNodeSelection);
                GUI.color = m_colorBuffer;
            }
        }
Exemple #15
0
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);
            if (m_dropdownEditing)
            {
                PropertyType parameterType = (PropertyType)EditorGUIIntPopup(m_dropdownRect, (int)m_currentParameterType, AvailablePropertyTypeLabels, AvailablePropertyTypeValues, UIUtils.PropertyPopUp);
                if (parameterType != m_currentParameterType)
                {
                    ChangeParameterType(parameterType);
                    DropdownEditing = false;
                }
            }

            if (m_isEditingPicker && m_drawPicker && m_currentParameterType != PropertyType.Global)
            {
                Rect hitRect = m_previewRect;
                hitRect.height = 14 * drawInfo.InvertedZoom;
                hitRect.y      = m_previewRect.yMax - hitRect.height;
                hitRect.width  = 4 * 14 * drawInfo.InvertedZoom;

                bool restoreMouse = false;
                if (Event.current.type == EventType.MouseDown && hitRect.Contains(drawInfo.MousePosition))
                {
                    restoreMouse       = true;
                    Event.current.type = EventType.Ignore;
                }

                EditorGUI.BeginChangeCheck();
                m_colorBuffer = GUI.color;
                GUI.color     = Color.clear;
                Type currType = (m_autocastMode == AutoCastType.Auto) ? typeof(Texture) : m_textureType;
                if (m_materialMode)
                {
                    m_materialValue = EditorGUIObjectField(m_previewRect, m_materialValue, currType, false) as Texture;
                }
                else
                {
                    m_defaultValue = EditorGUIObjectField(m_previewRect, m_defaultValue, currType, false) as Texture;
                }
                GUI.color = m_colorBuffer;

                if (EditorGUI.EndChangeCheck())
                {
                    CheckTextureImporter(true);
                    SetTitleText(m_propertyInspectorName);
                    SetAdditonalTitleText(string.Format(Constants.PropertyValueLabel, GetPropertyValStr()));
                    ConfigureInputPorts();
                    ConfigureOutputPorts();
                    BeginDelayedDirtyProperty();
                    PreviewIsDirty = true;
                }
                //else if( drawInfo.CurrentEventType == EventType.ExecuteCommand )
                //{
                //	GUI.FocusControl( null );
                //	m_isEditingPicker = false;
                //}

                if (restoreMouse)
                {
                    Event.current.type = EventType.MouseDown;
                }

                if ((drawInfo.CurrentEventType == EventType.MouseDown || drawInfo.CurrentEventType == EventType.MouseUp))
                {
                    DrawPreviewMaskButtonsLayout(drawInfo, m_previewRect);
                }
            }

            if (!m_drawPicker)
            {
                return;
            }

            if (drawInfo.CurrentEventType == EventType.Repaint)
            {
                DrawTexturePicker(drawInfo);
            }
        }
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);
            Rect rect = m_globalPosition;

            rect.x      = rect.x + (Constants.NodeButtonDeltaX - 1) * drawInfo.InvertedZoom + 1;
            rect.y      = rect.y + Constants.NodeButtonDeltaY * drawInfo.InvertedZoom;
            rect.width  = Constants.NodeButtonSizeX * drawInfo.InvertedZoom;
            rect.height = Constants.NodeButtonSizeY * drawInfo.InvertedZoom;
            EditorGUI.BeginChangeCheck();
            m_selectedOutputTypeInt = EditorGUIPopup(rect, m_selectedOutputTypeInt, m_outputValueTypes, UIUtils.PropertyPopUp);
            if (EditorGUI.EndChangeCheck())
            {
                switch (m_selectedOutputTypeInt)
                {
                case 0: m_selectedOutputType = WirePortDataType.FLOAT; break;

                case 1: m_selectedOutputType = WirePortDataType.FLOAT2; break;

                case 2: m_selectedOutputType = WirePortDataType.FLOAT3; break;

                case 3: m_selectedOutputType = WirePortDataType.FLOAT4; break;
                }

                UpdatePorts();
            }

            string additionalText = string.Empty;
            int    count          = 0;

            switch (m_selectedOutputType)
            {
            case WirePortDataType.FLOAT4:
            case WirePortDataType.COLOR:
                count = 4;
                break;

            case WirePortDataType.FLOAT3:
                count = 3;
                break;

            case WirePortDataType.FLOAT2:
                count = 2;
                break;

            case WirePortDataType.INT:
            case WirePortDataType.FLOAT:
                count = 1;
                break;

            case WirePortDataType.OBJECT:
            case WirePortDataType.FLOAT3x3:
            case WirePortDataType.FLOAT4x4:
                break;
            }
            for (int i = 0; i < count; i++)
            {
                additionalText += GetSwizzleComponentForChannel(m_selectedOutputSwizzleTypes[i]).ToUpper();
            }

            if (additionalText.Length > 0)
            {
                SetAdditonalTitleText("Value( " + additionalText + " )");
            }
            else
            {
                SetAdditonalTitleText(string.Empty);
            }
        }
 public override void Draw(DrawInfo drawInfo)
 {
     base.Draw(drawInfo);
     m_upperLeftWidget.DrawWidget <NoiseGeneratorType>(ref m_type, this, OnWidgetUpdate);
 }
 public override void Draw(DrawInfo drawInfo)
 {
     base.Draw(drawInfo);
     m_upperLeftWidget.DrawWidget <ViewSpace>(ref m_viewDirSpace, this, OnWidgetUpdate);
 }
Exemple #19
0
        public override void Draw(DrawInfo drawInfo)
        {
            if (m_initialized)
            {
                Color bufferedColor = GUI.color;
                if (m_nodesIds.Count > 0)
                {
                    for (int i = 0; i < m_nodesIds.Count; i++)
                    {
                        ParentNode node = UIUtils.CurrentWindow.CurrentGraph.GetNode(m_nodesIds[i]);
                        if (node)
                        {
                            AddNodeToCommentary(node);
                        }
                    }
                    m_nodesIds.Clear();
                }

                if (m_reRegisterNodes)
                {
                    m_reRegisterNodes = false;
                    m_nodesOnCommentaryDict.Clear();
                    for (int i = 0; i < m_nodesOnCommentary.Count; i++)
                    {
                        if (m_nodesOnCommentary[i] != null)
                        {
                            m_nodesOnCommentary[i].OnNodeStoppedMovingEvent += NodeStoppedMoving;
                            m_nodesOnCommentaryDict.Add(m_nodesOnCommentary[i].UniqueId, m_nodesOnCommentary[i]);
                        }
                    }
                }

                CalculatePositionAndVisibility(drawInfo);
                // Render Node
                GUI.color = Constants.NodeBodyColor;
                GUI.Box(m_globalPosition, string.Empty, UIUtils.CustomStyle(CustomStyle.CommentaryBackground));

                GUI.color = Color.white;
                Rect commentArea = m_globalPosition;
                commentArea.y     -= 1;
                commentArea.height = COMMENTARY_BOX_HEIGHT * drawInfo.InvertedZoom;
                commentArea.width *= 0.93f;

                GUI.color               = m_headerColor;
                m_headerPosition        = m_globalPosition;
                m_headerPosition.height = UIUtils.CurrentHeaderHeight;
                GUI.Box(m_headerPosition, string.Empty, UIUtils.CustomStyle(CustomStyle.NodeHeader));

                GUI.color = bufferedColor;
                if (m_selected)
                {
                    GUI.Box(m_globalPosition, string.Empty, UIUtils.CustomStyle(CustomStyle.NodeWindowOn));
                }


                m_commentText = EditorGUI.TextField(commentArea, string.Empty, m_commentText, UIUtils.CustomStyle(CustomStyle.CommentaryTitle));

                if (m_resizeIconTex == null)
                {
                    m_resizeIconTex = UIUtils.CustomStyle(CustomStyle.CommentaryResizeButton).normal.background;
                }


                // RIGHT RESIZE BUTTON

                m_resizeRightIconCoords        = m_globalPosition;
                m_resizeRightIconCoords.x      = m_globalPosition.x + m_globalPosition.width - 1 - (m_resizeIconTex.width + ResizeButtonPos.x) * drawInfo.InvertedZoom;
                m_resizeRightIconCoords.y      = m_globalPosition.y + m_globalPosition.height - 2 - (m_resizeIconTex.height + ResizeButtonPos.y) * drawInfo.InvertedZoom;
                m_resizeRightIconCoords.width  = m_resizeIconTex.width * drawInfo.InvertedZoom;
                m_resizeRightIconCoords.height = m_resizeIconTex.height * drawInfo.InvertedZoom;

                if (GUI.RepeatButton(m_resizeRightIconCoords, string.Empty, UIUtils.CustomStyle(CustomStyle.CommentaryResizeButton)))
                {
                    if (!m_isResizingRight && !m_isResizingLeft)
                    {
                        m_isResizingRight = true;
                        UIUtils.CurrentWindow.ForceAutoPanDir = true;
                        m_resizeStartPoint = drawInfo.TransformedMousePos;
                        UIUtils.CurrentWindow.CurrentGraph.MarkToDeselect();
                        UIUtils.CurrentWindow.CurrentGraph.MarkToSelect(m_uniqueId);
                    }
                }

                if (m_isResizingRight)
                {
                    if (drawInfo.CurrentEventType == EventType.mouseUp)
                    {
                        m_isResizingRight = false;
                        UIUtils.CurrentWindow.ForceAutoPanDir = false;
                        RemoveAllNodes();
                        FireStoppedMovingEvent(false, InteractionMode.Target);
                    }
                    else
                    {
                        Vector2 currSize = (drawInfo.TransformedMousePos - m_resizeStartPoint) / drawInfo.InvertedZoom;
                        m_resizeStartPoint = drawInfo.TransformedMousePos;
                        if (m_resizeAxis != eResizeAxis.Y_AXIS)
                        {
                            m_position.width += currSize.x;
                            if (m_position.width < MIN_SIZE_X)
                            {
                                m_position.width = MIN_SIZE_X;
                            }
                        }

                        if (m_resizeAxis != eResizeAxis.X_AXIS)
                        {
                            m_position.height += currSize.y;
                            if (m_position.height < MIN_SIZE_Y)
                            {
                                m_position.height = MIN_SIZE_Y;
                            }
                        }
                    }
                }


                /// LEFT RESIZE BUTTON
                m_resizeLeftIconCoords        = m_globalPosition;
                m_resizeLeftIconCoords.x      = m_globalPosition.x + 2;
                m_resizeLeftIconCoords.y      = m_globalPosition.y + m_globalPosition.height - 2 - (m_resizeIconTex.height + ResizeButtonPos.y) * drawInfo.InvertedZoom;
                m_resizeLeftIconCoords.width  = m_resizeIconTex.width * drawInfo.InvertedZoom;
                m_resizeLeftIconCoords.height = m_resizeIconTex.height * drawInfo.InvertedZoom;

                if (GUI.RepeatButton(m_resizeLeftIconCoords, string.Empty, UIUtils.CustomStyle(CustomStyle.CommentaryResizeButtonInv)))
                {
                    if (!m_isResizingRight && !m_isResizingLeft)
                    {
                        m_isResizingLeft = true;
                        UIUtils.CurrentWindow.ForceAutoPanDir = true;
                        m_resizeStartPoint = drawInfo.TransformedMousePos;
                        UIUtils.CurrentWindow.CurrentGraph.MarkToDeselect();
                        UIUtils.CurrentWindow.CurrentGraph.MarkToSelect(m_uniqueId);
                    }
                }

                if (m_isResizingLeft)
                {
                    if (drawInfo.CurrentEventType == EventType.mouseUp)
                    {
                        m_isResizingLeft = false;
                        UIUtils.CurrentWindow.ForceAutoPanDir = false;
                        RemoveAllNodes();
                        FireStoppedMovingEvent(false, InteractionMode.Target);
                    }
                    else
                    {
                        Vector2 currSize = (drawInfo.TransformedMousePos - m_resizeStartPoint) / drawInfo.InvertedZoom;
                        m_resizeStartPoint = drawInfo.TransformedMousePos;
                        if (m_resizeAxis != eResizeAxis.Y_AXIS)
                        {
                            m_position.x     += currSize.x;
                            m_position.width -= currSize.x;
                            if (m_position.width < MIN_SIZE_X)
                            {
                                m_position.x    -= (MIN_SIZE_X - m_position.width);
                                m_position.width = MIN_SIZE_X;
                            }
                        }

                        if (m_resizeAxis != eResizeAxis.X_AXIS)
                        {
                            m_position.height += currSize.y;
                            if (m_position.height < MIN_SIZE_Y)
                            {
                                m_position.height = MIN_SIZE_Y;
                            }
                        }
                    }
                }
                GUI.color = bufferedColor;
            }
        }
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);

            if (!m_isVisible)
            {
                return;
            }

            if (m_isEditingFields && m_currentParameterType != PropertyType.Global)
            {
                if (m_materialMode && m_currentParameterType != PropertyType.Constant)
                {
                    EditorGUI.BeginChangeCheck();
                    if (m_floatMode)
                    {
                        UIUtils.DrawFloat(this, ref m_propertyDrawPos, ref m_materialValue, LabelWidth * drawInfo.InvertedZoom);
                    }
                    else
                    {
                        DrawSlider(ref m_materialValue, drawInfo);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_requireMaterialUpdate = true;
                        if (m_currentParameterType != PropertyType.Constant)
                        {
                            BeginDelayedDirtyProperty();
                        }
                    }
                }
                else
                {
                    EditorGUI.BeginChangeCheck();

                    if (m_floatMode)
                    {
                        UIUtils.DrawFloat(this, ref m_propertyDrawPos, ref m_defaultValue, LabelWidth * drawInfo.InvertedZoom);
                    }
                    else
                    {
                        DrawSlider(ref m_defaultValue, drawInfo);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        BeginDelayedDirtyProperty();
                    }
                }
            }
            else if (drawInfo.CurrentEventType == EventType.Repaint && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4)
            {
                if (m_currentParameterType == PropertyType.Global)
                {
                    bool guiEnabled = GUI.enabled;
                    GUI.enabled = false;
                    DrawFakeFloatMaterial(drawInfo);
                    GUI.enabled = guiEnabled;
                }
                else if (m_materialMode && m_currentParameterType != PropertyType.Constant)
                {
                    DrawFakeFloatMaterial(drawInfo);
                }
                else
                {
                    if (m_floatMode)
                    {
                        //UIUtils.DrawFloat( this, ref m_propertyDrawPos, ref m_defaultValue, LabelWidth * drawInfo.InvertedZoom );
                        Rect fakeField = m_propertyDrawPos;
                        fakeField.xMin += LabelWidth * drawInfo.InvertedZoom;
                        Rect fakeLabel = m_propertyDrawPos;
                        fakeLabel.xMax = fakeField.xMin;
                        EditorGUIUtility.AddCursorRect(fakeLabel, MouseCursor.SlideArrow);
                        EditorGUIUtility.AddCursorRect(fakeField, MouseCursor.Text);

                        if (m_previousValue[0] != m_defaultValue)
                        {
                            m_previousValue[0] = m_defaultValue;
                            m_fieldText[0]     = m_defaultValue.ToString();
                        }

                        GUI.Label(fakeField, m_fieldText[0], UIUtils.MainSkin.textField);
                    }
                    else
                    {
                        DrawFakeSlider(ref m_defaultValue, drawInfo);
                    }
                }
            }
        }
Exemple #21
0
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);

            // Custom Editable Title
            if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD3)
            {
                if (!m_isEditing && ((!ContainerGraph.ParentWindow.MouseInteracted && drawInfo.CurrentEventType == EventType.MouseDown && m_commentArea.Contains(drawInfo.MousePosition))))
                {
                    if ((EditorApplication.timeSinceStartup - m_clickTime) < m_doubleClickTime)
                    {
                        m_startEditing = true;
                    }
                    else
                    {
                        GUI.FocusControl(null);
                    }
                    m_clickTime = EditorApplication.timeSinceStartup;
                }
                else if (m_isEditing && ((drawInfo.CurrentEventType == EventType.MouseDown && !m_commentArea.Contains(drawInfo.MousePosition)) || !EditorGUIUtility.editingTextField))
                {
                    m_stopEditing = true;
                }

                if (m_isEditing || m_startEditing)
                {
                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName(m_focusName);
                    m_commentText = EditorGUITextField(m_commentArea, string.Empty, m_commentText, UIUtils.GetCustomStyle(CustomStyle.CommentaryTitle));
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_checkCommentText = true;
                    }

                    if (m_startEditing)
                    {
                        EditorGUI.FocusTextInControl(m_focusName);
                    }
                }

                if (drawInfo.CurrentEventType == EventType.Repaint)
                {
                    if (m_startEditing)
                    {
                        m_startEditing = false;
                        m_isEditing    = true;
                    }

                    if (m_stopEditing)
                    {
                        m_stopEditing = false;
                        m_isEditing   = false;
                        GUI.FocusControl(null);
                    }
                }
            }

            if (drawInfo.CurrentEventType == EventType.MouseDown && drawInfo.LeftMouseButtonPressed)
            {
                // Left Button
                if (m_resizeLeftIconCoords.Contains(drawInfo.MousePosition) && ContainerGraph.ParentWindow.CurrentEvent.modifiers != EventModifiers.Shift)
                {
                    if (!m_isResizingLeft)
                    {
                        m_isResizingLeft = true;
                        ContainerGraph.ParentWindow.ForceAutoPanDir = true;
                        m_resizeStartPoint = drawInfo.TransformedMousePos;
                    }
                }

                // Right Button
                if (m_resizeRightIconCoords.Contains(drawInfo.MousePosition) && ContainerGraph.ParentWindow.CurrentEvent.modifiers != EventModifiers.Shift)
                {
                    if (!m_isResizingRight)
                    {
                        m_isResizingRight = true;
                        ContainerGraph.ParentWindow.ForceAutoPanDir = true;
                        m_resizeStartPoint = drawInfo.TransformedMousePos;
                    }
                }
            }

            if (drawInfo.CurrentEventType == EventType.Repaint || drawInfo.CurrentEventType == EventType.MouseUp)
            {
                // Left Button
                EditorGUIUtility.AddCursorRect(m_resizeLeftIconCoords, MouseCursor.ResizeUpRight);
                if (m_isResizingLeft)
                {
                    if (drawInfo.CurrentEventType == EventType.MouseUp)
                    {
                        m_isResizingLeft = false;
                        ContainerGraph.ParentWindow.ForceAutoPanDir = false;
                        RemoveAllNodes();
                        FireStoppedMovingEvent(false, InteractionMode.Target);
                    }
                    else
                    {
                        Vector2 currSize = (drawInfo.TransformedMousePos - m_resizeStartPoint) /*/ drawInfo.InvertedZoom*/;
                        m_resizeStartPoint = drawInfo.TransformedMousePos;
                        if (m_resizeAxis != eResizeAxis.Y_AXIS)
                        {
                            m_position.x     += currSize.x;
                            m_position.width -= currSize.x;
                            if (m_position.width < MIN_SIZE_X)
                            {
                                m_position.x    -= (MIN_SIZE_X - m_position.width);
                                m_position.width = MIN_SIZE_X;
                            }
                        }

                        if (m_resizeAxis != eResizeAxis.X_AXIS)
                        {
                            m_position.height += currSize.y;
                            if (m_position.height < MIN_SIZE_Y)
                            {
                                m_position.height = MIN_SIZE_Y;
                            }
                        }
                    }
                }

                // Right Button
                EditorGUIUtility.AddCursorRect(m_resizeRightIconCoords, MouseCursor.ResizeUpLeft);
                if (m_isResizingRight)
                {
                    if (drawInfo.CurrentEventType == EventType.MouseUp)
                    {
                        m_isResizingRight = false;
                        ContainerGraph.ParentWindow.ForceAutoPanDir = false;
                        RemoveAllNodes();
                        FireStoppedMovingEvent(false, InteractionMode.Target);
                    }
                    else
                    {
                        Vector2 currSize = (drawInfo.TransformedMousePos - m_resizeStartPoint) /*/ drawInfo.InvertedZoom*/;
                        m_resizeStartPoint = drawInfo.TransformedMousePos;
                        if (m_resizeAxis != eResizeAxis.Y_AXIS)
                        {
                            m_position.width += currSize.x;
                            if (m_position.width < MIN_SIZE_X)
                            {
                                m_position.width = MIN_SIZE_X;
                            }
                        }

                        if (m_resizeAxis != eResizeAxis.X_AXIS)
                        {
                            m_position.height += currSize.y;
                            if (m_position.height < MIN_SIZE_Y)
                            {
                                m_position.height = MIN_SIZE_Y;
                            }
                        }
                    }
                }
            }

            if (m_checkCommentText)
            {
                m_checkCommentText = false;
                m_commentText      = m_commentText.Replace(IOUtils.FIELD_SEPARATOR, ' ');
            }

            if (m_checkTitleText)
            {
                m_checkTitleText = false;
                m_titleText      = m_titleText.Replace(IOUtils.FIELD_SEPARATOR, ' ');
            }

            if (m_focusOnTitle && drawInfo.CurrentEventType == EventType.KeyUp)
            {
                m_focusOnTitle = false;
                m_startEditing = true;
            }
        }
        void DrawFakeSlider(ref float value, DrawInfo drawInfo)
        {
            float rangeWidth   = 30 * drawInfo.InvertedZoom;
            float rangeSpacing = 5 * drawInfo.InvertedZoom;

            //Min
            Rect minRect = m_propertyDrawPos;

            minRect.width = rangeWidth;
            EditorGUIUtility.AddCursorRect(minRect, MouseCursor.Text);
            if (m_previousValue[1] != m_min)
            {
                m_previousValue[1] = m_min;
                m_fieldText[1]     = m_min.ToString();
            }
            GUI.Label(minRect, m_fieldText[1], UIUtils.MainSkin.textField);

            //Value Area
            Rect valRect = m_propertyDrawPos;

            valRect.width = rangeWidth;
            valRect.x     = m_propertyDrawPos.xMax - rangeWidth - rangeWidth - rangeSpacing;
            EditorGUIUtility.AddCursorRect(valRect, MouseCursor.Text);
            if (m_previousValue[0] != value)
            {
                m_previousValue[0] = value;
                m_fieldText[0]     = value.ToString();
            }
            GUI.Label(valRect, m_fieldText[0], UIUtils.MainSkin.textField);

            //Max
            Rect maxRect = m_propertyDrawPos;

            maxRect.width = rangeWidth;
            maxRect.x     = m_propertyDrawPos.xMax - rangeWidth;
            EditorGUIUtility.AddCursorRect(maxRect, MouseCursor.Text);
            if (m_previousValue[2] != m_max)
            {
                m_previousValue[2] = m_max;
                m_fieldText[2]     = m_max.ToString();
            }
            GUI.Label(maxRect, m_fieldText[2], UIUtils.MainSkin.textField);

            Rect sliderValRect = m_propertyDrawPos;

            sliderValRect.x    = minRect.xMax + rangeSpacing;
            sliderValRect.xMax = valRect.xMin - rangeSpacing;
            Rect sliderBackRect = sliderValRect;

            sliderBackRect.height = 5 * drawInfo.InvertedZoom;
            sliderBackRect.center = new Vector2(sliderValRect.center.x, Mathf.Round(sliderValRect.center.y));


            GUI.Label(sliderBackRect, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SliderStyle));

            sliderValRect.width = 10;
            float percent = (value - m_min) / (m_max - m_min);

            sliderValRect.x += percent * (sliderBackRect.width - 10 * drawInfo.InvertedZoom);
            GUI.Label(sliderValRect, string.Empty, UIUtils.RangedFloatSliderThumbStyle);
        }
Exemple #23
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);
            }

            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;
            }
        }
Exemple #24
0
        public override void Draw(DrawInfo drawInfo)
        {
            if (m_firstFrame)
            {
                m_firstFrame = false;
                Init();
            }

            if (m_topTexture.ReRegisterName)
            {
                m_topTexture.ReRegisterName = false;
                UIUtils.RegisterUniformName(UniqueId, m_topTexture.PropertyName);
            }
            m_topTexture.CheckDelayedDirtyProperty();
            m_topTexture.CheckPropertyFromInspector();

            if (m_selectedTriplanarType == TriplanarType.Cylindrical)
            {
                if (m_midTexture.ReRegisterName)
                {
                    m_midTexture.ReRegisterName = false;
                    UIUtils.RegisterUniformName(UniqueId, m_midTexture.PropertyName);
                }
                m_midTexture.CheckDelayedDirtyProperty();
                m_midTexture.CheckPropertyFromInspector();

                if (m_botTexture.ReRegisterName)
                {
                    m_botTexture.ReRegisterName = false;
                    UIUtils.RegisterUniformName(UniqueId, m_botTexture.PropertyName);
                }
                m_botTexture.CheckDelayedDirtyProperty();
                m_botTexture.CheckPropertyFromInspector();
            }

            base.Draw(drawInfo);
            //return;
            Rect startPicker = m_previewRect;

            startPicker.x     -= 43 * drawInfo.InvertedZoom;
            startPicker.width  = 43 * drawInfo.InvertedZoom;
            startPicker.height = 43 * drawInfo.InvertedZoom;

            m_topTexPropRef = m_topTexture;
            if (m_inputPorts[0].IsConnected)
            {
                m_topTexPropRef = m_inputPorts[0].GetOutputNode(0) as TexturePropertyNode;
                if (GUI.Button(startPicker, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerTextureRef)))
                {
                    UIUtils.FocusOnNode(m_topTexPropRef, 1, true);
                }

                if (m_topTexPropRef.Value != null)
                {
                    EditorGUI.DrawPreviewTexture(startPicker, m_topTexPropRef.Value);
                }
            }
            else
            {
                if (m_materialMode)
                {
                    EditorGUI.BeginChangeCheck();
                    m_topTexPropRef.MaterialValue = EditorGUIObjectField(startPicker, m_topTexPropRef.MaterialValue, typeof(Texture), false) as Texture;
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_requireMaterialUpdate = true;
                    }
                }
                else
                {
                    m_topTexPropRef.DefaultValue = EditorGUIObjectField(startPicker, m_topTexPropRef.DefaultValue, typeof(Texture), false) as Texture;
                }
            }

            // Mid
            if (m_selectedTriplanarType == TriplanarType.Cylindrical)
            {
                startPicker.y += startPicker.height;

                m_midTexPropRef = m_midTexture;
                if (m_inputPorts[1].IsConnected)
                {
                    m_midTexPropRef = m_inputPorts[1].GetOutputNode(0) as TexturePropertyNode;
                    if (GUI.Button(startPicker, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerTextureRef)))
                    {
                        UIUtils.FocusOnNode(m_midTexPropRef, 1, true);
                    }

                    if (m_midTexPropRef.Value != null)
                    {
                        EditorGUI.DrawPreviewTexture(startPicker, m_midTexPropRef.Value);
                    }
                }
                else
                {
                    if (m_materialMode)
                    {
                        EditorGUI.BeginChangeCheck();
                        m_midTexPropRef.MaterialValue = EditorGUIObjectField(startPicker, m_midTexPropRef.MaterialValue, typeof(Texture), false) as Texture;
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_requireMaterialUpdate = true;
                        }
                    }
                    else
                    {
                        m_midTexPropRef.DefaultValue = EditorGUIObjectField(startPicker, m_midTexPropRef.DefaultValue, typeof(Texture), false) as Texture;
                    }
                }

                startPicker.y     += startPicker.height;
                startPicker.height = 42 * drawInfo.InvertedZoom;

                m_botTexPropRef = m_botTexture;
                if (m_inputPorts[2].IsConnected)
                {
                    m_botTexPropRef = m_inputPorts[2].GetOutputNode(0) as TexturePropertyNode;
                    if (GUI.Button(startPicker, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerTextureRef)))
                    {
                        UIUtils.FocusOnNode(m_botTexPropRef, 1, true);
                    }

                    if (m_botTexPropRef.Value != null)
                    {
                        EditorGUI.DrawPreviewTexture(startPicker, m_botTexPropRef.Value);
                    }
                }
                else
                {
                    if (m_materialMode)
                    {
                        EditorGUI.BeginChangeCheck();
                        m_botTexPropRef.MaterialValue = EditorGUIObjectField(startPicker, m_botTexPropRef.MaterialValue, typeof(Texture), false) as Texture;
                        if (EditorGUI.EndChangeCheck())
                        {
                            m_requireMaterialUpdate = true;
                        }
                    }
                    else
                    {
                        m_botTexPropRef.DefaultValue = EditorGUIObjectField(startPicker, m_botTexPropRef.DefaultValue, typeof(Texture), false) as Texture;
                    }
                }
            }
        }
Exemple #25
0
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);

            if (!m_isVisible)
            {
                return;
            }

            if (m_isEditingFields && m_currentParameterType != PropertyType.Global)
            {
                EditorGUI.BeginChangeCheck();
                for (int i = 0; i < 4; i++)
                {
                    m_propertyDrawPos.y = m_outputPorts[i + 1].Position.y - 2 * drawInfo.InvertedZoom;
                    if (m_materialMode && m_currentParameterType != PropertyType.Constant)
                    {
                        float val = m_materialValue[i];
                        UIUtils.DrawFloat(this, ref m_propertyDrawPos, ref val, LabelWidth * drawInfo.InvertedZoom);
                        m_materialValue[i] = val;
                    }
                    else
                    {
                        float val = m_defaultValue[i];
                        UIUtils.DrawFloat(this, ref m_propertyDrawPos, ref val, LabelWidth * drawInfo.InvertedZoom);
                        m_defaultValue[i] = val;
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    PreviewIsDirty          = true;
                    m_requireMaterialUpdate = m_materialMode;
                    BeginDelayedDirtyProperty();
                    //m_propertyNameIsDirty = true;
                }
            }
            else if (drawInfo.CurrentEventType == EventType.Repaint && ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD4)
            {
                bool guiEnabled = GUI.enabled;
                GUI.enabled = m_currentParameterType != PropertyType.Global;

                for (int i = 0; i < 4; i++)
                {
                    m_propertyDrawPos.y = m_outputPorts[i + 1].Position.y - 2 * drawInfo.InvertedZoom;

                    Rect fakeField = m_propertyDrawPos;
                    fakeField.xMin += LabelWidth * drawInfo.InvertedZoom;
                    if (GUI.enabled)
                    {
                        Rect fakeLabel = m_propertyDrawPos;
                        fakeLabel.xMax = fakeField.xMin;
                        EditorGUIUtility.AddCursorRect(fakeLabel, MouseCursor.SlideArrow);
                        EditorGUIUtility.AddCursorRect(fakeField, MouseCursor.Text);
                    }
                    if (m_materialMode && m_currentParameterType != PropertyType.Constant)
                    {
                        if (m_previousValue[i] != m_materialValue[i])
                        {
                            m_previousValue[i] = m_materialValue[i];
                            m_fieldText[i]     = m_materialValue[i].ToString();
                        }
                    }
                    else
                    {
                        if (m_previousValue[i] != m_defaultValue[i])
                        {
                            m_previousValue[i] = m_defaultValue[i];
                            m_fieldText[i]     = m_defaultValue[i].ToString();
                        }
                    }

                    GUI.Label(fakeField, m_fieldText[i], UIUtils.MainSkin.textField);
                }
                GUI.enabled = guiEnabled;
            }
        }
 public override void Draw(DrawInfo drawInfo)
 {
     base.Draw(drawInfo);
     m_upperLeftWidget.DrawWidget <BlendOps>(ref m_currentBlendOp, this, OnWidgetUpdate);
 }
 public override void Draw(DrawInfo drawInfo)
 {
     base.Draw(drawInfo);
     m_upperLeftWidget.DrawWidget <BillboardType>(ref m_billboardType, this, OnWidgetUpdate);
 }
Exemple #28
0
 public override void OnNodeLayout(DrawInfo drawInfo)
 {
     base.OnNodeLayout(drawInfo);
     ConfigTextureType();
 }
 public override void OnNodeLogicUpdate(DrawInfo drawInfo)
 {
     base.OnNodeLogicUpdate(drawInfo);
     UpdateLocalVar();
 }
Exemple #30
0
        public override void Draw(DrawInfo drawInfo)
        {
            base.Draw(drawInfo);
            if (m_isVisible)
            {
                if (m_floatMode)
                {
                    m_propertyDrawPos.x      = m_remainingBox.x - LabelWidth * drawInfo.InvertedZoom;
                    m_propertyDrawPos.y      = m_outputPorts[0].Position.y - 2 * drawInfo.InvertedZoom;
                    m_propertyDrawPos.width  = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_WIDTH_FIELD_SIZE;
                    m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE;
                }
                else
                {
                    m_propertyDrawPos.x      = m_remainingBox.x;
                    m_propertyDrawPos.y      = m_outputPorts[0].Position.y - 2 * drawInfo.InvertedZoom;
                    m_propertyDrawPos.width  = 0.7f * m_globalPosition.width;
                    m_propertyDrawPos.height = drawInfo.InvertedZoom * Constants.FLOAT_DRAW_HEIGHT_FIELD_SIZE;
                }

                if (m_materialMode && m_currentParameterType != PropertyType.Constant)
                {
                    EditorGUI.BeginChangeCheck();
                    if (m_floatMode)
                    {
                        UIUtils.DrawFloat(ref m_propertyDrawPos, ref m_materialValue, LabelWidth * drawInfo.InvertedZoom);
                    }
                    else
                    {
                        DrawSlider(ref m_materialValue, drawInfo);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_requireMaterialUpdate = true;
                        if (m_currentParameterType != PropertyType.Constant)
                        {
                            //MarkForPreviewUpdate();
                            BeginDelayedDirtyProperty();
                        }
                    }
                }
                else
                {
                    EditorGUI.BeginChangeCheck();

                    if (m_floatMode)
                    {
                        UIUtils.DrawFloat(ref m_propertyDrawPos, ref m_defaultValue, LabelWidth * drawInfo.InvertedZoom);
                    }
                    else
                    {
                        DrawSlider(ref m_defaultValue, drawInfo);
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        //MarkForPreviewUpdate();
                        BeginDelayedDirtyProperty();
                    }
                }
            }
        }