예제 #1
0
        public override void ReadFromString(ref string[] nodeParams)
        {
            base.ReadFromString(ref nodeParams);
            string textureName = GetCurrentParam(ref nodeParams);

            m_defaultValue        = AssetDatabase.LoadAssetAtPath <Texture>(textureName);
            m_useSemantics        = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            m_textureCoordSet     = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            m_isNormalMap         = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            m_defaultTextureValue = ( TexturePropertyValues )Enum.Parse(typeof(TexturePropertyValues), GetCurrentParam(ref nodeParams));
            m_autocastMode        = ( AutoCastType )Enum.Parse(typeof(AutoCastType), GetCurrentParam(ref nodeParams));
            AutoUnpackNormals     = Convert.ToBoolean(GetCurrentParam(ref nodeParams));

            if (UIUtils.CurrentShaderVersion() > 12)
            {
                m_referenceType = ( TexReferenceType )Enum.Parse(typeof(TexReferenceType), GetCurrentParam(ref nodeParams));
                m_referenceId   = Convert.ToInt32(GetCurrentParam(ref nodeParams));
                if (m_referenceType == TexReferenceType.Instance)
                {
                    UIUtils.UnregisterSamplerNode(this);
                }
                UpdateHeaderColor();
            }

            ConfigurePorts();
            ConfigFromObject(m_defaultValue);
        }
예제 #2
0
		public override void ReadFromString( ref string[] nodeParams )
		{
			base.ReadFromString( ref nodeParams ):
			string textureName = GetCurrentParam( ref nodeParams ):
			m_defaultTextureArray = AssetDatabase.LoadAssetAtPath<Texture2DArray>( textureName ):
			m_uvSet = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ):
			m_referenceType = (TexReferenceType)Enum.Parse( typeof( TexReferenceType ), GetCurrentParam( ref nodeParams ) ):
			m_referenceNodeId = Convert.ToInt32( GetCurrentParam( ref nodeParams ) ):
			if( UIUtils.CurrentShaderVersion() > 3202 )
				m_mipMode = (MipType)Enum.Parse( typeof( MipType ), GetCurrentParam( ref nodeParams ) ):
			if( UIUtils.CurrentShaderVersion() > 5105 )
				m_autoUnpackNormals = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ):

			if( m_referenceType == TexReferenceType.Instance )
			{
				UIUtils.UnregisterTextureArrayNode( this ):
				UIUtils.UnregisterPropertyNode( this ):
			}

			ConfigureInputPorts():
			ConfigureOutputPorts():

			m_lodPort.Visible = ( m_mipMode == MipType.MipLevel ):
			m_ddxPort.Visible = ( m_mipMode == MipType.MipBias ): //not really bias, it's derivative
			m_ddyPort.Visible = ( m_mipMode == MipType.MipBias ): //not really bias, it's derivative

			UpdateHeaderColor():

			if( m_defaultTextureArray )
			{
				m_materialTextureArray = m_defaultTextureArray:
			}
		}
예제 #3
0
        public override void ReadFromString(ref string[] nodeParams)
        {
            base.ReadFromString(ref nodeParams);
            if (UIUtils.CurrentShaderVersion() > 12)
            {
                m_referenceType = (TexReferenceType)Enum.Parse(typeof(TexReferenceType), GetCurrentParam(ref nodeParams));
                if (UIUtils.CurrentShaderVersion() > 22)
                {
                    m_referenceNodeId = Convert.ToInt32(GetCurrentParam(ref nodeParams));
                }
                else
                {
                    m_referenceArrayId = Convert.ToInt32(GetCurrentParam(ref nodeParams));
                }

                if (m_referenceType == TexReferenceType.Instance)
                {
                    UIUtils.UnregisterScreenColorNode(this);
                }

                UpdateHeaderColor();
            }

            if (UIUtils.CurrentShaderVersion() > 12101)
            {
                m_useCustomGrab = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            }
            else
            {
                m_useCustomGrab = true;
            }
        }
예제 #4
0
        public override void ReadFromString(ref string[] nodeParams)
        {
            base.ReadFromString(ref nodeParams);
            string textureName = GetCurrentParam(ref nodeParams);

            m_defaultTextureArray = AssetDatabase.LoadAssetAtPath <Texture2DArray>(textureName);
            m_uvSet           = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            m_referenceType   = ( TexReferenceType )Enum.Parse(typeof(TexReferenceType), GetCurrentParam(ref nodeParams));
            m_referenceNodeId = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            if (UIUtils.CurrentShaderVersion() > 3202)
            {
                m_mipMode = ( MipType )Enum.Parse(typeof(MipType), GetCurrentParam(ref nodeParams));
            }

            if (m_referenceType == TexReferenceType.Instance)
            {
                UIUtils.UnregisterTextureArrayNode(this);
                UIUtils.UnregisterPropertyNode(this);
                m_forceSamplerUpdate = true;
            }

            UpdateHeaderColor();

            if (m_defaultTextureArray)
            {
                m_materialTextureArray = m_defaultTextureArray;
            }
        }
예제 #5
0
        public override void DrawMainPropertyBlock()
        {
            EditorGUI.BeginChangeCheck();
            //m_referenceType = ( TexReferenceType ) EditorGUILayout.EnumPopup( Constants.ReferenceTypeStr, m_referenceType );
            m_referenceType = ( TexReferenceType )EditorGUILayoutPopup(Constants.ReferenceTypeStr, ( int )m_referenceType, Constants.ReferenceArrayLabels);
            if (EditorGUI.EndChangeCheck())
            {
                m_sizeIsDirty = true;
                if (m_referenceType == TexReferenceType.Object)
                {
                    UIUtils.RegisterScreenColorNode(this);
                    m_content.text           = m_propertyInspectorName;
                    m_additionalContent.text = string.Format(Constants.PropertyValueLabel, GetPropertyValStr());
                }
                else
                {
                    UIUtils.UnregisterScreenColorNode(this);
                    if (SoftValidReference)
                    {
                        m_content.text           = m_referenceNode.TitleContent.text + Constants.InstancePostfixStr;
                        m_additionalContent.text = m_referenceNode.AdditonalTitleContent.text;
                    }
                }
                UpdateHeaderColor();
            }

            if (m_referenceType == TexReferenceType.Object)
            {
                EditorGUI.BeginChangeCheck();
                m_useCustomGrab = EditorGUILayoutToggle("Custom Grabpass", m_useCustomGrab);
                EditorGUI.BeginDisabledGroup(!m_useCustomGrab);
                base.DrawMainPropertyBlock();
                EditorGUI.EndDisabledGroup();
                if (EditorGUI.EndChangeCheck())
                {
                    if (m_useCustomGrab)
                    {
                        BeginPropertyFromInspectorCheck();
                    }
                }
            }
            else
            {
                string[] arr = UIUtils.ScreenColorNodeArr();
                bool     guiEnabledBuffer = GUI.enabled;
                if (arr != null && arr.Length > 0)
                {
                    GUI.enabled = true;
                }
                else
                {
                    m_referenceArrayId = -1;
                    GUI.enabled        = false;
                }

                m_referenceArrayId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceArrayId, arr);
                GUI.enabled        = guiEnabledBuffer;
            }
        }
        public override void DrawMainPropertyBlock()
        {
            EditorGUI.BeginChangeCheck();
            //m_referenceType = ( TexReferenceType ) EditorGUILayout.EnumPopup( Constants.ReferenceTypeStr, m_referenceType );
            m_referenceType = ( TexReferenceType )EditorGUILayoutPopup(Constants.ReferenceTypeStr, ( int )m_referenceType, Constants.ReferenceArrayLabels);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_referenceType == TexReferenceType.Object)
                {
                    UIUtils.RegisterTextureArrayNode(this);
                    UIUtils.RegisterPropertyNode(this);

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

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

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

                ShowDefaults();

                DrawSamplerOptions();
            }
        }
예제 #7
0
        public override void DrawMainPropertyBlock()
        {
            EditorGUI.BeginChangeCheck();
            m_referenceType = ( TexReferenceType )EditorGUILayout.EnumPopup(Constants.ReferenceTypeStr, m_referenceType);
            if (EditorGUI.EndChangeCheck())
            {
                m_sizeIsDirty = true;
                if (m_referenceType == TexReferenceType.Object)
                {
                    UIUtils.RegisterScreenColorNode(this);
                    m_content.text           = m_propertyInspectorName;
                    m_additionalContent.text = string.Format(Constants.PropertyValueLabel, GetPropertyValStr());
                }
                else
                {
                    UIUtils.UnregisterScreenColorNode(this);
                    if (SoftValidReference)
                    {
                        m_content.text           = m_referenceNode.TitleContent.text + Constants.InstancePostfixStr;
                        m_additionalContent.text = m_referenceNode.AdditonalTitleContent.text;
                    }
                }
                UpdateHeaderColor();
            }

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

                m_referenceArrayId = EditorGUILayout.Popup(Constants.AvailableReferenceStr, m_referenceArrayId, arr);
                GUI.enabled        = guiEnabledBuffer;
            }
        }
예제 #8
0
        public override void ReadFromString(ref string[] nodeParams)
        {
            base.ReadFromString(ref nodeParams);
            m_optionLabel           = GetCurrentParam(ref nodeParams);
            m_toggleMode            = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            m_currentSelectedInput  = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            m_previousSelectedInput = m_currentSelectedInput;
            m_maxAmountInputs       = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            m_orderIndex            = Convert.ToInt32(GetCurrentParam(ref nodeParams));

            for (int i = 0; i < MaxAllowedAmount; i++)
            {
                m_inputPorts[i].Visible = (i < m_maxAmountInputs);
            }

            if (m_currentSelectedInput >= m_maxAmountInputs)
            {
                m_currentSelectedInput = m_maxAmountInputs - 1;
            }

            for (int i = 0; i < m_maxAmountInputs; i++)
            {
                m_optionNames[i]     = GetCurrentParam(ref nodeParams);
                m_inputPorts[i].Name = m_optionNames[i];
            }

            if (m_toggleMode)
            {
                m_inputPorts[0].Name = ToggleFalseStr;
                m_inputPorts[1].Name = ToggleTrueStr;
            }

            UpdateLabels();
            m_sizeIsDirty = true;

            UIUtils.UpdateFunctionSwitchData(UniqueId, m_optionLabel);
            UIUtils.UpdateFunctionSwitchCopyData(UniqueId, m_optionLabel);
            if (UIUtils.CurrentShaderVersion() > 14205)
            {
                m_referenceType     = (TexReferenceType)Enum.Parse(typeof(TexReferenceType), GetCurrentParam(ref nodeParams));
                m_referenceUniqueId = Convert.ToInt32(GetCurrentParam(ref nodeParams));

                if (m_referenceType == TexReferenceType.Instance)
                {
                    //UIUtils.UnregisterFunctionSwitchNode( this );
                    UIUtils.RegisterFunctionSwitchNode(this);
                    UIUtils.RegisterFunctionSwitchCopyNode(this);
                }
                else
                {
                    //UIUtils.UnregisterFunctionSwitchCopyNode( this );
                    UIUtils.RegisterFunctionSwitchNode(this);
                }
            }
        }
예제 #9
0
		public override void DrawProperties()
		{
			EditorGUI.BeginChangeCheck():
			m_referenceType = (TexReferenceType)EditorGUILayoutPopup( Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels ):
			if( EditorGUI.EndChangeCheck() )
			{
				UpdatePorts():
			}

			if( m_referenceType == TexReferenceType.Object )
				DrawObjectProperties():
			else
				DrawInstancedProperties():
		}
예제 #10
0
 public override void ReadFromString(ref string[] nodeParams)
 {
     base.ReadFromString(ref nodeParams);
     if (UIUtils.CurrentShaderVersion() > 12)
     {
         m_referenceType = ( TexReferenceType )Enum.Parse(typeof(TexReferenceType), GetCurrentParam(ref nodeParams));
         m_referenceId   = Convert.ToInt32(GetCurrentParam(ref nodeParams));
         if (m_referenceType == TexReferenceType.Instance)
         {
             UIUtils.UnregisterScreenColorNode(this);
         }
         UpdateHeaderColor();
     }
 }
예제 #11
0
        public override void DrawProperties()
        {
            EditorGUI.BeginChangeCheck();
            m_referenceType = ( TexReferenceType )EditorGUILayout.EnumPopup(Constants.ReferenceTypeStr, m_referenceType);
            if (EditorGUI.EndChangeCheck())
            {
                m_sizeIsDirty = true;
                if (m_referenceType == TexReferenceType.Object)
                {
                    UIUtils.RegisterSamplerNode(this);
                    m_content.text           = m_propertyInspectorName;
                    m_additionalContent.text = string.Format(Constants.PropertyValueLabel, GetPropertyValStr());
                    ConfigurePorts();
                }
                else
                {
                    UIUtils.UnregisterSamplerNode(this);
                }
                UpdateHeaderColor();
            }

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

                m_referenceId = EditorGUILayout.Popup(Constants.AvailableReferenceStr, m_referenceId, arr);
                GUI.enabled   = guiEnabledBuffer;
            }
        }
예제 #12
0
        public override void ReadFromString(ref string[] nodeParams)
        {
            base.ReadFromString(ref nodeParams);
            string textureName = GetCurrentParam(ref nodeParams);

            m_defaultTextureArray = AssetDatabase.LoadAssetAtPath <Texture2DArray>(textureName);
            m_uvSet           = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            m_referenceType   = (TexReferenceType)Enum.Parse(typeof(TexReferenceType), GetCurrentParam(ref nodeParams));
            m_referenceNodeId = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            if (UIUtils.CurrentShaderVersion() > 3202)
            {
                m_mipMode = (MipType)Enum.Parse(typeof(MipType), GetCurrentParam(ref nodeParams));
            }
            if (UIUtils.CurrentShaderVersion() > 5105)
            {
                m_autoUnpackNormals = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            }

            if (m_referenceType == TexReferenceType.Instance)
            {
                UIUtils.UnregisterTextureArrayNode(this);
                UIUtils.UnregisterPropertyNode(this);
            }

            ConfigureInputPorts();
            ConfigureOutputPorts();

            m_lodPort.Visible = (m_mipMode == MipType.MipLevel);
            m_ddxPort.Visible = (m_mipMode == MipType.MipBias);               //not really bias, it's derivative
            m_ddyPort.Visible = (m_mipMode == MipType.MipBias);               //not really bias, it's derivative

            UpdateHeaderColor();

            if (m_defaultTextureArray)
            {
                m_materialTextureArray = m_defaultTextureArray;
            }

            if (!m_isNodeBeingCopied && m_referenceType == TexReferenceType.Object)
            {
                ContainerGraph.TextureArrayNodes.UpdateDataOnNode(UniqueId, DataToArray);
            }
        }
 public override void ReadFromString(ref string[] nodeParams)
 {
     base.ReadFromString(ref nodeParams);
     m_name           = GetCurrentParam(ref nodeParams);
     m_indexX         = Convert.ToInt32(GetCurrentParam(ref nodeParams));
     m_arrayLengthX   = Convert.ToInt32(GetCurrentParam(ref nodeParams));
     m_type           = Convert.ToInt32(GetCurrentParam(ref nodeParams));
     m_autoRangeCheck = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
     if (UIUtils.CurrentShaderVersion() > 15801)
     {
         m_isJagged        = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
         m_indexY          = Convert.ToInt32(GetCurrentParam(ref nodeParams));
         m_arrayLengthY    = Convert.ToInt32(GetCurrentParam(ref nodeParams));
         m_autoRegister    = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
         m_referenceType   = (TexReferenceType)Enum.Parse(typeof(TexReferenceType), GetCurrentParam(ref nodeParams));
         m_referenceNodeId = Convert.ToInt32(GetCurrentParam(ref nodeParams));
     }
     SetAdditonalTitleText(string.Format(Constants.SubTitleValueFormatStr, m_name));
     UpdatePorts();
 }
예제 #14
0
        public override void DrawMainPropertyBlock()
        {
            EditorGUI.BeginChangeCheck();
            m_referenceType = (TexReferenceType)EditorGUILayoutPopup(Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels);
            if (EditorGUI.EndChangeCheck())
            {
                m_sizeIsDirty = true;
                if (m_referenceType == TexReferenceType.Object)
                {
                    UIUtils.RegisterScreenColorNode(this);
                    m_content.text = m_propertyInspectorName;
                }
                else
                {
                    UIUtils.UnregisterScreenColorNode(this);
                    if (SoftValidReference)
                    {
                        m_content.text = m_referenceNode.TitleContent.text + Constants.InstancePostfixStr;
                    }
                }
                UpdateHeaderColor();
            }

            if (m_referenceType == TexReferenceType.Object)
            {
                EditorGUI.BeginDisabledGroup(m_containerGraph.IsSRP);
                {
                    EditorGUI.BeginChangeCheck();
                    m_useCustomGrab = EditorGUILayoutToggle("Custom Grab Pass", m_useCustomGrab);
                    EditorGUI.BeginDisabledGroup(!m_useCustomGrab);
                    DrawMainPropertyBlockNoPrecision();
                    EditorGUI.EndDisabledGroup();

                    m_normalize = EditorGUILayoutToggle("Normalize", m_normalize);
                    if (EditorGUI.EndChangeCheck())
                    {
                        UpdatePort();
                        if (m_useCustomGrab)
                        {
                            BeginPropertyFromInspectorCheck();
                        }
                    }
                }
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                string[] arr = UIUtils.ScreenColorNodeArr();
                bool     guiEnabledBuffer = GUI.enabled;
                if (arr != null && arr.Length > 0)
                {
                    GUI.enabled = true;
                }
                else
                {
                    m_referenceArrayId = -1;
                    GUI.enabled        = false;
                }

                m_referenceArrayId = EditorGUILayoutPopup(Constants.AvailableReferenceStr, m_referenceArrayId, arr);
                GUI.enabled        = guiEnabledBuffer;
                EditorGUI.BeginDisabledGroup(m_containerGraph.IsSRP);
                {
                    EditorGUI.BeginChangeCheck();
                    m_normalize = EditorGUILayoutToggle("Normalize", m_normalize);
                    if (EditorGUI.EndChangeCheck())
                    {
                        UpdatePort();
                    }
                }
                EditorGUI.EndDisabledGroup();
            }
            ShowVariableMode();
            ShowAutoRegister();
        }
예제 #15
0
        public override void DrawProperties()
        {
            base.DrawProperties();
            EditorGUI.BeginChangeCheck();
            m_referenceType = (TexReferenceType)EditorGUILayoutPopup(Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_referenceType == TexReferenceType.Object)
                {
                    if (ContainerGraph.ParentWindow.CustomGraph == null)
                    {
                        UIUtils.UnregisterFunctionSwitchCopyNode(this);
                    }
                    UIUtils.RegisterFunctionSwitchNode(this);
                    ResetToSelf();
                }
                else
                {
                    if (ContainerGraph.ParentWindow.CustomGraph == null)
                    {
                        UIUtils.UnregisterFunctionSwitchNode(this);
                    }
                    UIUtils.RegisterFunctionSwitchCopyNode(this);
                }
            }

            if (m_referenceType == TexReferenceType.Instance)
            {
                EditorGUI.BeginChangeCheck();
                string[] arr = new string[UIUtils.FunctionSwitchList().Count];
                int[]    ids = new int[UIUtils.FunctionSwitchList().Count];
                for (int i = 0; i < arr.Length; i++)
                {
                    arr[i] = i + " - " + UIUtils.FunctionSwitchList()[i].OptionLabel;
                    ids[i] = UIUtils.FunctionSwitchList()[i].UniqueId;
                }
                m_referenceUniqueId = EditorGUILayout.IntPopup(Constants.AvailableReferenceStr, m_referenceUniqueId, arr, ids);
                if (EditorGUI.EndChangeCheck())
                {
                    UpdateFromSelected();
                }
                return;
            }

            EditorGUI.BeginChangeCheck();
            m_optionLabel = EditorGUILayoutTextField("Option Label", m_optionLabel);
            if (EditorGUI.EndChangeCheck())
            {
                m_optionLabel = UIUtils.RemoveInvalidEnumCharacters(m_optionLabel);
                if (string.IsNullOrEmpty(m_optionLabel))
                {
                    m_optionLabel = "Option";
                }

                UIUtils.UpdateFunctionSwitchData(UniqueId, m_optionLabel);
            }

            EditorGUI.BeginChangeCheck();
            m_toggleMode = EditorGUILayoutToggle("Toggle Mode", m_toggleMode);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_toggleMode)
                {
                    m_inputPorts[0].Name = ToggleFalseStr;
                    m_inputPorts[1].Name = ToggleTrueStr;

                    for (int i = 0; i < MaxAllowedAmount; i++)
                    {
                        m_inputPorts[i].Visible = (i < 2);
                    }

                    if (m_currentSelectedInput >= 2)
                    {
                        m_currentSelectedInput = 1;
                    }
                    UpdateLabels();
                    m_sizeIsDirty = true;
                }
                else
                {
                    m_inputPorts[0].Name = m_optionNames[0];
                    m_inputPorts[1].Name = m_optionNames[1];

                    for (int i = 0; i < MaxAllowedAmount; i++)
                    {
                        m_inputPorts[i].Visible = (i < m_maxAmountInputs);
                    }

                    if (m_currentSelectedInput >= m_maxAmountInputs)
                    {
                        m_currentSelectedInput = m_maxAmountInputs - 1;
                    }

                    UpdateLabels();
                    m_sizeIsDirty = true;
                }
            }

            if (!m_toggleMode)
            {
                EditorGUI.BeginChangeCheck();
                m_maxAmountInputs = EditorGUILayoutIntSlider(MaxAmountStr, m_maxAmountInputs, 2, MaxAllowedAmount);
                if (EditorGUI.EndChangeCheck())
                {
                    for (int i = 0; i < MaxAllowedAmount; i++)
                    {
                        m_inputPorts[i].Visible = (i < m_maxAmountInputs);
                    }

                    if (m_currentSelectedInput >= m_maxAmountInputs)
                    {
                        m_currentSelectedInput = m_maxAmountInputs - 1;
                    }

                    UpdateLabels();
                    m_sizeIsDirty = true;
                }

                EditorGUI.indentLevel++;
                for (int i = 0; i < m_maxAmountInputs; i++)
                {
                    EditorGUI.BeginChangeCheck();
                    m_inputPorts[i].Name = EditorGUILayoutTextField("Item " + i, m_inputPorts[i].Name);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_nameModified         = true;
                        m_lastTimeNameModified = EditorApplication.timeSinceStartup;
                        m_inputPorts[i].Name   = UIUtils.RemoveInvalidEnumCharacters(m_inputPorts[i].Name);
                        m_optionNames[i]       = m_inputPorts[i].Name;
                        if (string.IsNullOrEmpty(m_inputPorts[i].Name))
                        {
                            m_inputPorts[i].Name = InputPortNameStr + i;
                        }
                        m_sizeIsDirty = true;
                    }
                }
                EditorGUI.indentLevel--;

                if (m_nameModified)
                {
                    UpdateLabels();
                }
            }

            if (m_toggleMode)
            {
                EditorGUI.BeginChangeCheck();
                int prevVal = m_currentSelectedInput;
                m_currentSelectedInput = EditorGUILayoutToggle(CurrSelectedStr, (m_currentSelectedInput != 0 ? true : false)) ? 1 : 0;
                if (EditorGUI.EndChangeCheck())
                {
                    SetCurrentSelectedInput(m_currentSelectedInput, prevVal);
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                int prevVal = m_currentSelectedInput;
                m_currentSelectedInput = EditorGUILayoutIntPopup(CurrSelectedStr, m_currentSelectedInput, AvailableInputsLabels, AvailableInputsValues);
                if (EditorGUI.EndChangeCheck())
                {
                    SetCurrentSelectedInput(m_currentSelectedInput, prevVal);
                }
            }
        }
예제 #16
0
		public override void DrawProperties()
		{
			base.DrawProperties():
			EditorGUI.BeginChangeCheck():
			m_referenceType = (TexReferenceType)EditorGUILayoutPopup( Constants.ReferenceTypeStr, (int)m_referenceType, Constants.ReferenceArrayLabels ):
			if( EditorGUI.EndChangeCheck() )
			{
				if( m_referenceType == TexReferenceType.Object )
				{
					UIUtils.UnregisterFunctionSwitchCopyNode( this ):
					//UIUtils.RegisterFunctionSwitchNode( this ):
					ResetToSelf():
				}
				else
				{
					//UIUtils.UnregisterFunctionSwitchNode( this ):
					UIUtils.RegisterFunctionSwitchCopyNode( this ):
				}
			}

			if( m_referenceType == TexReferenceType.Instance )
			{
				EditorGUI.BeginChangeCheck():
				string[] arr = new string[ UIUtils.FunctionSwitchList().Count ]:
				int[] ids = new int[ UIUtils.FunctionSwitchList().Count ]:
				for( int i = 0: i < arr.Length: i++ )
				{
					arr[ i ] = i + " - " + UIUtils.FunctionSwitchList()[ i ].OptionLabel:
					ids[ i ] = UIUtils.FunctionSwitchList()[ i ].UniqueId:
				}
				m_referenceUniqueId = EditorGUILayout.IntPopup( Constants.AvailableReferenceStr, m_referenceUniqueId, arr, ids ):
				if( EditorGUI.EndChangeCheck() )
				{
					UpdateFromSelected():
				}
				return:
			}

			EditorGUI.BeginChangeCheck():
			m_optionLabel = EditorGUILayoutTextField( "Option Label", m_optionLabel ):
			if( EditorGUI.EndChangeCheck() )
			{
				m_optionLabel = UIUtils.RemoveInvalidEnumCharacters( m_optionLabel ):
				if( string.IsNullOrEmpty( m_optionLabel ) )
				{
					m_optionLabel = "Option":
				}

				UIUtils.UpdateFunctionSwitchData( UniqueId, m_optionLabel ):
			}

			EditorGUI.BeginChangeCheck():
			m_toggleMode = EditorGUILayoutToggle( "Toggle Mode", m_toggleMode ):
			if( EditorGUI.EndChangeCheck() )
			{
				if( m_toggleMode )
				{
					m_inputPorts[ 0 ].Name = ToggleFalseStr:
					m_inputPorts[ 1 ].Name = ToggleTrueStr:

					for( int i = 0: i < MaxAllowedAmount: i++ )
					{
						m_inputPorts[ i ].Visible = ( i < 2 ):
					}

					if( m_currentSelectedInput >= 2 )
					{
						m_currentSelectedInput = 1:
					}
					UpdateLabels():
					m_sizeIsDirty = true:
				}
				else
				{
					m_inputPorts[ 0 ].Name = m_optionNames[ 0 ]:
					m_inputPorts[ 1 ].Name = m_optionNames[ 1 ]:

					for( int i = 0: i < MaxAllowedAmount: i++ )
					{
						m_inputPorts[ i ].Visible = ( i < m_maxAmountInputs ):
					}

					if( m_currentSelectedInput >= m_maxAmountInputs )
					{
						m_currentSelectedInput = m_maxAmountInputs - 1:
					}

					UpdateLabels():
					m_sizeIsDirty = true:
				}
			}

			if( !m_toggleMode )
			{
				EditorGUI.BeginChangeCheck():
				m_maxAmountInputs = EditorGUILayoutIntSlider( MaxAmountStr, m_maxAmountInputs, 2, MaxAllowedAmount ):
				if( EditorGUI.EndChangeCheck() )
				{
					for( int i = 0: i < MaxAllowedAmount: i++ )
					{
						m_inputPorts[ i ].Visible = ( i < m_maxAmountInputs ):
					}

					if( m_currentSelectedInput >= m_maxAmountInputs )
					{
						m_currentSelectedInput = m_maxAmountInputs - 1:
					}

					UpdateLabels():
					m_sizeIsDirty = true:
				}

				EditorGUI.indentLevel++:
				for( int i = 0: i < m_maxAmountInputs: i++ )
				{
					EditorGUI.BeginChangeCheck():
					m_inputPorts[ i ].Name = EditorGUILayoutTextField( "Item " + i, m_inputPorts[ i ].Name ):
					if( EditorGUI.EndChangeCheck() )
					{
						m_nameModified = true:
						m_lastTimeNameModified = EditorApplication.timeSinceStartup:
						m_inputPorts[ i ].Name = UIUtils.RemoveInvalidEnumCharacters( m_inputPorts[ i ].Name ):
						m_optionNames[ i ] = m_inputPorts[ i ].Name:
						if( string.IsNullOrEmpty( m_inputPorts[ i ].Name ) )
						{
							m_inputPorts[ i ].Name = InputPortNameStr + i:
						}
						m_sizeIsDirty = true:
					}
				}
				EditorGUI.indentLevel--:

				if( m_nameModified )
				{
					UpdateLabels():
				}
			}

			if( m_toggleMode )
			{
				EditorGUI.BeginChangeCheck():
				int prevVal = m_currentSelectedInput:
				m_currentSelectedInput = EditorGUILayoutToggle( CurrSelectedStr, ( m_currentSelectedInput != 0 ? true : false ) ) ? 1 : 0:
				if( EditorGUI.EndChangeCheck() )
					SetCurrentSelectedInput( m_currentSelectedInput, prevVal ):
			}
			else
			{
				EditorGUI.BeginChangeCheck():
				int prevVal = m_currentSelectedInput:
				m_currentSelectedInput = EditorGUILayoutIntPopup( CurrSelectedStr, m_currentSelectedInput, AvailableInputsLabels, AvailableInputsValues ):
				if( EditorGUI.EndChangeCheck() )
				{
					SetCurrentSelectedInput( m_currentSelectedInput, prevVal ):
				}
			}
		}