Exemple #1
0
        public bool Draw(Rect parentPosition, ParentNode selectedNode, Vector2 mousePosition, int mouseButtonId, bool hasKeyboardFocus)
        {
            bool changeCheck = false;

            base.Draw(parentPosition, mousePosition, mouseButtonId, hasKeyboardFocus);
            if (m_nodePropertiesStyle == null)
            {
                m_nodePropertiesStyle = UIUtils.GetCustomStyle(CustomStyle.NodePropertiesTitle);
                m_nodePropertiesStyle.normal.textColor = m_nodePropertiesStyle.active.textColor = EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f) : new Color(0f, 0f, 0f);
            }

            if (m_isMaximized)
            {
                KeyCode key = Event.current.keyCode;
                if (m_isMouseInside || hasKeyboardFocus)
                {
                    if (key == ShortcutsManager.ScrollUpKey)
                    {
                        m_currentScrollPos.y -= 10;
                        if (m_currentScrollPos.y < 0)
                        {
                            m_currentScrollPos.y = 0;
                        }
                        Event.current.Use();
                    }

                    if (key == ShortcutsManager.ScrollDownKey)
                    {
                        m_currentScrollPos.y += 10;
                        Event.current.Use();
                    }
                }

                if (m_forceUpdate)
                {
                    if (m_propertyReordableList != null)
                    {
                        m_propertyReordableList.ReleaseKeyboardFocus();
                    }
                    m_propertyReordableList = null;

                    if (m_functionInputsReordableList != null)
                    {
                        m_functionInputsReordableList.ReleaseKeyboardFocus();
                    }
                    m_functionInputsReordableList = null;

                    if (m_functionSwitchesReordableList != null)
                    {
                        m_functionSwitchesReordableList.ReleaseKeyboardFocus();
                    }
                    m_functionSwitchesReordableList = null;

                    if (m_functionOutputsReordableList != null)
                    {
                        m_functionOutputsReordableList.ReleaseKeyboardFocus();
                    }
                    m_functionOutputsReordableList = null;
                    m_forceUpdate = false;
                }

                GUILayout.BeginArea(m_transformedArea, m_content, m_style);
                {
                    //Draw selected node parameters
                    if (selectedNode != null)
                    {
                        // this hack is need because without it the several FloatFields/Textfields/... would show wrong values ( different from the ones they were assigned to show )
                        if (m_lastSelectedNode != selectedNode.UniqueId)
                        {
                            m_lastSelectedNode = selectedNode.UniqueId;
                            GUI.FocusControl("");
                        }

                        EditorGUILayout.BeginVertical();
                        {
                            EditorGUILayout.Separator();
                            if (selectedNode.UniqueId == ParentWindow.CurrentGraph.CurrentMasterNodeId)
                            {
                                m_dummyContent.text = "Output Node";
                            }
                            else
                            {
                                if (selectedNode.Attributes != null)
                                {
                                    m_dummyContent.text = selectedNode.Attributes.Name;
                                }
                                else if (selectedNode is CommentaryNode)
                                {
                                    m_dummyContent.text = "Commentary";
                                }
                                else
                                {
                                    m_dummyContent.text = TitleStr;
                                }
                            }

                            EditorGUILayout.LabelField(m_dummyContent, m_nodePropertiesStyle);

                            EditorGUILayout.Separator();
                            //UIUtils.RecordObject( selectedNode , "Changing properties on node " + selectedNode.UniqueId);
                            m_currentScrollPos = EditorGUILayout.BeginScrollView(m_currentScrollPos, GUILayout.Width(0), GUILayout.Height(0));
                            float labelWidth = EditorGUIUtility.labelWidth;
                            if (selectedNode.TextLabelWidth > 0)
                            {
                                EditorGUIUtility.labelWidth = selectedNode.TextLabelWidth;
                            }

                            changeCheck = selectedNode.SafeDrawProperties();
                            EditorGUIUtility.labelWidth = labelWidth;
                            EditorGUILayout.EndScrollView();
                        }
                        EditorGUILayout.EndVertical();

                        if (changeCheck)
                        {
                            if (selectedNode.ConnStatus == NodeConnectionStatus.Connected)
                            {
                                ParentWindow.SetSaveIsDirty();
                            }
                        }
                    }
                    else
                    {
                        //Draw Graph Params
                        EditorGUILayout.BeginVertical();
                        {
                            EditorGUILayout.Separator();
                            EditorGUILayout.LabelField("Graph Properties", m_nodePropertiesStyle);
                            EditorGUILayout.Separator();

                            m_currentScrollPos = EditorGUILayout.BeginScrollView(m_currentScrollPos, GUILayout.Width(0), GUILayout.Height(0));
                            float labelWidth = EditorGUIUtility.labelWidth;
                            EditorGUIUtility.labelWidth = 90;

                            bool generalIsVisible = EditorVariablesManager.ExpandedGeneralShaderOptions.Value;
                            NodeUtils.DrawPropertyGroup(ref generalIsVisible, " General", DrawGeneralFunction);
                            EditorVariablesManager.ExpandedGeneralShaderOptions.Value = generalIsVisible;
                            AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction;
                            if (function != null)
                            {
                                function.AdditionalIncludes.Draw(ParentWindow.CurrentGraph.CurrentOutputNode);
                                function.AdditionalPragmas.Draw(ParentWindow.CurrentGraph.CurrentOutputNode);
                            }

                            bool inputIsVisible = EditorVariablesManager.ExpandedFunctionInputs.Value;
                            NodeUtils.DrawPropertyGroup(ref inputIsVisible, " Function Inputs", DrawFunctionInputs);
                            EditorVariablesManager.ExpandedFunctionInputs.Value = inputIsVisible;

                            bool swicthIsVisible = EditorVariablesManager.ExpandedFunctionSwitches.Value;
                            NodeUtils.DrawPropertyGroup(ref swicthIsVisible, " Function Switches", DrawFunctionSwitches);
                            EditorVariablesManager.ExpandedFunctionSwitches.Value = swicthIsVisible;

                            bool outputIsVisible = EditorVariablesManager.ExpandedFunctionOutputs.Value;
                            NodeUtils.DrawPropertyGroup(ref outputIsVisible, " Function Outputs", DrawFunctionOutputs);
                            EditorVariablesManager.ExpandedFunctionOutputs.Value = outputIsVisible;

                            bool properties = ParentWindow.ExpandedProperties;
                            NodeUtils.DrawPropertyGroup(ref properties, " Material Properties", DrawFunctionProperties);
                            ParentWindow.ExpandedProperties = properties;

                            EditorGUIUtility.labelWidth = labelWidth;
                            EditorGUILayout.EndScrollView();
                        }
                        EditorGUILayout.EndVertical();
                    }
                }
                // Close window area
                GUILayout.EndArea();
            }

            PostDraw();
            return(changeCheck);
        }
Exemple #2
0
 public override void DrawProperties()
 {
     base.DrawProperties();
     NodeUtils.DrawPropertyGroup(ref m_visibleCustomAttrFoldout, CustomAttrStr, DrawCustomAttributes, DrawCustomAttrAddRemoveButtons);
 }
Exemple #3
0
        void OnGUI()
        {
            if (!UIUtils.Initialized || UIUtils.CurrentWindow == null)
            {
                EditorGUILayout.LabelField(NoASEWindowWarning);
                return;
            }

            if (m_init)
            {
                Init();
            }

            KeyCode key = Event.current.keyCode;

            if (key == ShortcutsManager.ScrollUpKey)
            {
                m_currentScrollPos.y -= 10;
                if (m_currentScrollPos.y < 0)
                {
                    m_currentScrollPos.y = 0;
                }
                Event.current.Use();
            }

            if (key == ShortcutsManager.ScrollDownKey)
            {
                m_currentScrollPos.y += 10;
                Event.current.Use();
            }

            if (Event.current.type == EventType.MouseDrag && Event.current.button > 0)
            {
                m_currentScrollPos.x += Constants.MenuDragSpeed * Event.current.delta.x;
                if (m_currentScrollPos.x < 0)
                {
                    m_currentScrollPos.x = 0;
                }

                m_currentScrollPos.y += Constants.MenuDragSpeed * Event.current.delta.y;
                if (m_currentScrollPos.y < 0)
                {
                    m_currentScrollPos.y = 0;
                }
            }

            m_availableArea = new Rect(WindowPosX, WindowPosY, position.width - 2 * WindowPosX, position.height - 2 * WindowPosY);
            GUILayout.BeginArea(m_availableArea);
            {
                if (GUILayout.Button("Wiki Page"))
                {
                    Application.OpenURL(Constants.HelpURL);
                }

                m_currentScrollPos = GUILayout.BeginScrollView(m_currentScrollPos);
                {
                    EditorGUILayout.BeginVertical();
                    {
                        NodeUtils.DrawPropertyGroup(ref m_portAreaFoldout, PortLegendTitle, DrawPortInfo);
                        float currLabelWidth = EditorGUIUtility.labelWidth;
                        EditorGUIUtility.labelWidth = 1;
                        NodeUtils.DrawPropertyGroup(ref m_editorShortcutAreaFoldout, EditorShortcutsTitle, DrawEditorShortcuts);
                        NodeUtils.DrawPropertyGroup(ref m_menuShortcutAreaFoldout, MenuShortcutsTitle, DrawMenuShortcuts);
                        NodeUtils.DrawPropertyGroup(ref m_nodesShortcutAreaFoldout, NodesShortcutsTitle, DrawNodesShortcuts);
                        NodeUtils.DrawPropertyGroup(ref m_compatibleAssetsFoldout, CompatibleAssetsTitle, DrawCompatibleAssets);
                        NodeUtils.DrawPropertyGroup(ref m_nodesDescriptionAreaFoldout, NodesDescTitle, DrawNodeDescriptions);
                        EditorGUIUtility.labelWidth = currLabelWidth;
                    }
                    EditorGUILayout.EndVertical();
                }
                GUILayout.EndScrollView();
            }
            GUILayout.EndArea();
        }
Exemple #4
0
 public override void DrawProperties()
 {
     //base.DrawProperties();
     NodeUtils.DrawPropertyGroup(ref m_propertiesFoldout, Constants.ParameterLabelStr, PropertyGroup);
     CheckPropertyFromInspector();
 }
Exemple #5
0
        public override void DrawProperties()
        {
            if (m_currentTemplate == null)
            {
                return;
            }

            base.DrawProperties();

            bool generalIsVisible = ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedGeneralShaderOptions;

            NodeUtils.DrawPropertyGroup(ref generalIsVisible, GeneralFoldoutStr, DrawGeneralOptions);
            ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedGeneralShaderOptions = generalIsVisible;

            if (m_currentTemplate.AlphaToMaskData.DataCheck == TemplateDataCheck.Valid)
            {
                m_alphaToMaskHelper.Draw(this);
            }

            if (m_currentTemplate.BlendData.DataCheck == TemplateDataCheck.Valid)
            {
                m_blendOpHelper.Draw(this);
            }


            if (m_currentTemplate.StencilData.DataCheck == TemplateDataCheck.Valid)
            {
                CullMode cullMode = (m_currentTemplate.CullModeData.DataCheck == TemplateDataCheck.Valid) ? m_cullModeHelper.CurrentCullMode : CullMode.Back;
                m_stencilBufferHelper.Draw(this, cullMode);
            }

            if (m_currentTemplate.DepthData.DataCheck == TemplateDataCheck.Valid)
            {
                m_depthOphelper.Draw(this);
            }

            if (m_currentTemplate.TagData.DataCheck == TemplateDataCheck.Valid)
            {
                m_tagsHelper.Draw(this);
            }

            DrawMaterialInputs(UIUtils.MenuItemToolbarStyle);

            //	NodeUtils.DrawPropertyGroup( ref m_snippetsFoldout, SnippetsFoldoutStr, DrawSnippetOptions );
            if (GUILayout.Button(OpenTemplateStr) && m_currentTemplate != null)
            {
                try
                {
                    string pathname = AssetDatabase.GUIDToAssetPath(m_currentTemplate.GUID);
                    if (!string.IsNullOrEmpty(pathname))
                    {
                        Shader selectedTemplate = AssetDatabase.LoadAssetAtPath <Shader>(pathname);
                        if (selectedTemplate != null)
                        {
                            AssetDatabase.OpenAsset(selectedTemplate, 1);
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

#if SHOW_TEMPLATE_HELP_BOX
            EditorGUILayout.HelpBox(WarningMessage, MessageType.Warning);
#endif
        }
Exemple #6
0
        public override void Draw(UndoParentNode currOwner, bool style = true)
        {
            m_currOwner = currOwner;
            if (m_reordableList == null)
            {
                m_reordableList = new ReorderableList(m_additionalDirectives, typeof(AdditionalDirectiveContainer), true, false, false, false)
                {
                    headerHeight          = 0,
                    footerHeight          = 0,
                    showDefaultBackground = false,
                    //elementHeightCallback = ( index ) =>
                    //{
                    //	if( m_additionalDirectives[index].Origin == AdditionalContainerOrigin.Native && m_nativeDirectivesFoldout )
                    //	{
                    //		return ( m_nativeDirectives.Count+1) * ( EditorGUIUtility.singleLineHeight ) + 5;
                    //	}

                    //	return EditorGUIUtility.singleLineHeight + 5;
                    //},
                    drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
                    {
                        //if( m_additionalDirectives[ index ].Origin == AdditionalContainerOrigin.Native && m_nativeDirectivesFoldout )
                        //{
                        //	rect.height = ( m_nativeDirectives.Count + 1 ) * ( EditorGUIUtility.singleLineHeight ) + 5;
                        //}

                        if (m_additionalDirectives[index] != null)
                        {
                            float labelWidthStyleAdjust = 0;
                            if (style)
                            {
                                rect.xMin            -= 10;
                                labelWidthStyleAdjust = 15;
                            }
                            else
                            {
                                rect.xMin -= 1;
                            }

                            float popUpWidth       = style ? 75 : 60f;
                            float widthAdjust      = m_additionalDirectives[index].LineType == AdditionalLineType.Include ? -14 : 0;
                            Rect  popupPos         = new Rect(rect.x, rect.y, popUpWidth, EditorGUIUtility.singleLineHeight);
                            Rect  GUIDTogglePos    = m_additionalDirectives[index].LineType == AdditionalLineType.Include ? new Rect(rect.x + rect.width - 3 * Constants.PlusMinusButtonLayoutWidth, rect.y, Constants.PlusMinusButtonLayoutWidth, Constants.PlusMinusButtonLayoutWidth) : new Rect();
                            Rect  buttonPlusPos    = new Rect(rect.x + rect.width - 2 * Constants.PlusMinusButtonLayoutWidth, rect.y - 2, Constants.PlusMinusButtonLayoutWidth, Constants.PlusMinusButtonLayoutWidth);
                            Rect  buttonMinusPos   = new Rect(rect.x + rect.width - Constants.PlusMinusButtonLayoutWidth, rect.y - 2, Constants.PlusMinusButtonLayoutWidth, Constants.PlusMinusButtonLayoutWidth);
                            float labelWidthBuffer = EditorGUIUtility.labelWidth;
                            Rect  labelPos         = new Rect(rect.x + popupPos.width - labelWidthStyleAdjust, rect.y, labelWidthStyleAdjust + rect.width - popupPos.width - buttonPlusPos.width - buttonMinusPos.width + widthAdjust, EditorGUIUtility.singleLineHeight);

                            //if( m_additionalDirectives[ index ].Origin == AdditionalContainerOrigin.Native )
                            //{
                            //	m_nativeRect = rect;
                            //	m_nativeRect.xMin += 2;
                            //	m_nativeRect.xMax -= 2;
                            //	m_nativeRect.yMax -= 2;
                            //	NodeUtils.DrawNestedPropertyGroup( ref m_nativeDirectivesFoldout, rect, NativeFoldoutStr, DrawNativeItems, 2 );
                            //	return;
                            //}

                            m_additionalDirectives[index].LineType = (AdditionalLineType)m_currOwner.EditorGUIEnumPopup(popupPos, m_additionalDirectives[index].LineType);

                            if (m_additionalDirectives[index].LineType == AdditionalLineType.Include)
                            {
                                if (m_additionalDirectives[index].GUIDToggle)
                                {
                                    //if( m_additionalDirectives[ index ].LibObject == null && !string.IsNullOrEmpty( m_additionalDirectives[ index ].GUIDValue ) )
                                    //{
                                    //	m_additionalDirectives[ index ].LibObject = AssetDatabase.LoadAssetAtPath<TextAsset>( AssetDatabase.GUIDToAssetPath( m_additionalDirectives[ index ].GUIDValue ) );
                                    //}

                                    EditorGUI.BeginChangeCheck();
                                    TextAsset obj = m_currOwner.EditorGUIObjectField(labelPos, m_additionalDirectives[index].LibObject, typeof(TextAsset), false) as TextAsset;
                                    if (EditorGUI.EndChangeCheck())
                                    {
                                        string pathName  = AssetDatabase.GetAssetPath(obj);
                                        string extension = Path.GetExtension(pathName);
                                        extension = extension.ToLower();
                                        if (extension.Equals(".cginc") || extension.Equals(".hlsl"))
                                        {
                                            m_additionalDirectives[index].LibObject = obj;
                                            m_additionalDirectives[index].GUIDValue = AssetDatabase.AssetPathToGUID(pathName);
                                        }
                                    }
                                }
                                else
                                {
                                    m_additionalDirectives[index].LineValue = m_currOwner.EditorGUITextField(labelPos, string.Empty, m_additionalDirectives[index].LineValue);
                                }

                                if (GUI.Button(GUIDTogglePos, m_additionalDirectives[index].GUIDToggle ? UIUtils.FloatIntIconOFF : UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF))
                                {
                                    m_additionalDirectives[index].GUIDToggle = !m_additionalDirectives[index].GUIDToggle;
                                }
                            }
                            else
                            {
                                m_additionalDirectives[index].LineValue = m_currOwner.EditorGUITextField(labelPos, string.Empty, m_additionalDirectives[index].LineValue);
                            }

                            if (GUI.Button(buttonPlusPos, string.Empty, UIUtils.PlusStyle))
                            {
                                m_actionType  = ReordableAction.Add;
                                m_actionIndex = index;
                            }

                            if (GUI.Button(buttonMinusPos, string.Empty, UIUtils.MinusStyle))
                            {
                                m_actionType  = ReordableAction.Remove;
                                m_actionIndex = index;
                            }
                        }
                    }
                };
            }

            if (m_actionType != ReordableAction.None)
            {
                switch (m_actionType)
                {
                case ReordableAction.Add:
                {
                    AdditionalDirectiveContainer newItem = ScriptableObject.CreateInstance <AdditionalDirectiveContainer>();
                    newItem.hideFlags = HideFlags.HideAndDontSave;
                    m_additionalDirectives.Insert(m_actionIndex + 1, newItem);
                }
                break;

                case ReordableAction.Remove:
                    AdditionalDirectiveContainer itemToDelete = m_additionalDirectives[m_actionIndex];
                    m_additionalDirectives.RemoveAt(m_actionIndex);
                    ScriptableObject.DestroyImmediate(itemToDelete);
                    break;
                }
                m_isDirty    = true;
                m_actionType = ReordableAction.None;
                EditorGUI.FocusTextInControl(null);
            }
            bool foldoutValue = currOwner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalDirectives;

            if (style)
            {
                NodeUtils.DrawPropertyGroup(ref foldoutValue, m_moduleName, DrawReordableList, DrawButtons);
            }
            else
            {
                NodeUtils.DrawNestedPropertyGroup(ref foldoutValue, m_moduleName, DrawReordableList, DrawButtons);
            }
            currOwner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalDirectives = foldoutValue;
        }