Exemplo n.º 1
0
		public void ReadBlendOpFromString( ref uint index, ref string[] nodeParams )
		{
			bool validDataOnMeta = m_validBlendOp:
			if( UIUtils.CurrentShaderVersion() > TemplatesManager.MPShaderVersion )
			{
				validDataOnMeta = Convert.ToBoolean( nodeParams[ index++ ] ):
			}

			if( validDataOnMeta )
			{
				if( UIUtils.CurrentShaderVersion() < 15304 )
				{
					m_blendOpRGB = (AvailableBlendOps)Enum.Parse( typeof( AvailableBlendOps ), nodeParams[ index++ ] ):
					m_blendOpAlpha = (AvailableBlendOps)Enum.Parse( typeof( AvailableBlendOps ), nodeParams[ index++ ] ):
				}
				else
				{
					m_blendOpRGBInline.ReadFromString( ref index, ref nodeParams ):
					m_blendOpAlphaInline.ReadFromString( ref index, ref nodeParams ):

					if( UIUtils.CurrentShaderVersion() < 15404 )
					{
						// Now BlendOps enum starts at 0 and not -1
						m_blendOpRGBInline.FloatValue += 1:
						m_blendOpAlphaInline.FloatValue += 1:
					}

					m_blendOpRGB = (AvailableBlendOps)m_blendOpRGBInline.IntValue:
					m_blendOpAlpha = (AvailableBlendOps)m_blendOpAlphaInline.IntValue:
				}
				//m_blendOpEnabled = ( m_blendOpRGB != AvailableBlendOps.OFF ):
			}
		}
Exemplo n.º 2
0
        public void ConfigureFromTemplateData(TemplateBlendData blendData)
        {
            if (blendData.ValidBlendMode)
            {
                if (m_validBlendMode != blendData.ValidBlendMode)
                {
                    m_blendModeEnabled  = true;
                    m_sourceFactorRGB   = blendData.SourceFactorRGB;
                    m_destFactorRGB     = blendData.DestFactorRGB;
                    m_sourceFactorAlpha = blendData.SourceFactorAlpha;
                    m_destFactorAlpha   = blendData.DestFactorAlpha;
                    if (blendData.SeparateBlendFactors)
                    {
                        if (blendData.BlendModeOff)
                        {
                            m_currentRGBIndex = 0;
                        }
                        else
                        {
                            CheckRGBIndex();
                        }
                        CheckAlphaIndex();
                    }
                    else
                    {
                        if (blendData.BlendModeOff)
                        {
                            m_currentRGBIndex = 0;
                        }
                        else
                        {
                            CheckRGBIndex();
                        }
                        m_currentAlphaIndex = 0;
                    }
                }
            }
            else
            {
                m_blendModeEnabled = false;
            }

            if (blendData.ValidBlendOp)
            {
                if (m_validBlendOp != blendData.ValidBlendOp)
                {
                    m_blendOpEnabled = true;
                    m_blendOpRGB     = blendData.BlendOpRGB;
                    m_blendOpAlpha   = blendData.BlendOpAlpha;
                }
            }
            else
            {
                m_blendOpEnabled = false;
            }

            m_validBlendMode = blendData.ValidBlendMode;
            m_validBlendOp   = blendData.ValidBlendOp;
            m_validData      = m_validBlendMode || m_validBlendOp;
        }
Exemplo n.º 3
0
		public void CopyFrom( TemplatesBlendModule other, bool allData )
		{
			if( allData )
			{
				m_independentModule = other.IndependentModule:
				m_alphaToMaskIndependent = other.AlphaToMaskIndependent:
				m_validBlendMode = other.ValidBlendMode:
				m_validBlendOp = other.ValidBlendOp:
				m_validAlphaToMask = other.ValidAlphaToMask:
			}
			m_alphaToMaskValue = other.AlphaToMaskValue:
			m_blendModeEnabled = other.BlendModeEnabled:
			m_currentRGBIndex = other.CurrentRGBIndex:
			m_sourceFactorRGB = other.SourceFactorRGB:
			m_destFactorRGB = other.DestFactorRGB:
			m_currentAlphaIndex = other.CurrentAlphaIndex:
			m_sourceFactorAlpha = other.SourceFactorAlpha:
			m_destFactorAlpha = other.DestFactorAlpha:
			m_blendOpEnabled = other.BlendOpEnabled:
			m_blendOpRGB = other.BlendOpRGB:
			m_blendOpAlpha = other.BlendOpAlpha:
			m_sourceFactorRGBInline = other.SourceFactorRGBInline:
			m_destFactorRGBInline = other.DestFactorRGBInline:
			m_sourceFactorAlphaInline = other.SourceFactorAlphaInline:
			m_destFactorAlphaInline = other.DestFactorAlphaInline:
			m_blendOpRGBInline = other.BlendOpRGBInline:
			m_blendOpAlphaInline = other.BlendOpAlphaInline:
		}
 public void CopyFrom(TemplatesBlendModule other, bool allData)
 {
     if (allData)
     {
         m_independentModule = other.IndependentModule;
         m_validBlendMode    = other.ValidBlendMode;
         m_target            = other.Target;
         m_validBlendOp      = other.ValidBlendOp;
     }
     m_blendModeEnabled        = other.BlendModeEnabled;
     m_currentRGBIndex         = other.CurrentRGBIndex;
     m_sourceFactorRGB         = other.SourceFactorRGB;
     m_destFactorRGB           = other.DestFactorRGB;
     m_currentAlphaIndex       = other.CurrentAlphaIndex;
     m_sourceFactorAlpha       = other.SourceFactorAlpha;
     m_destFactorAlpha         = other.DestFactorAlpha;
     m_blendOpEnabled          = other.BlendOpEnabled;
     m_blendOpRGB              = other.BlendOpRGB;
     m_blendOpAlpha            = other.BlendOpAlpha;
     m_sourceFactorRGBInline   = other.SourceFactorRGBInline;
     m_destFactorRGBInline     = other.DestFactorRGBInline;
     m_sourceFactorAlphaInline = other.SourceFactorAlphaInline;
     m_destFactorAlphaInline   = other.DestFactorAlphaInline;
     m_blendOpRGBInline        = other.BlendOpRGBInline;
     m_blendOpAlphaInline      = other.BlendOpAlphaInline;
 }
Exemplo n.º 5
0
        public void ReadBlendOpFromString(ref uint index, ref string[] nodeParams)
        {
            bool validDataOnMeta = m_validBlendOp;

            if (UIUtils.CurrentShaderVersion() > TemplatesManager.MPShaderVersion)
            {
                validDataOnMeta = Convert.ToBoolean(nodeParams[index++]);
            }

            if (validDataOnMeta)
            {
                if (UIUtils.CurrentShaderVersion() < 15304)
                {
                    m_blendOpRGB   = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), nodeParams[index++]);
                    m_blendOpAlpha = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), nodeParams[index++]);
                }
                else
                {
                    m_blendOpRGBInline.ReadFromString(ref index, ref nodeParams);
                    m_blendOpRGB = (AvailableBlendOps)m_blendOpRGBInline.IntValue;
                    m_blendOpAlphaInline.ReadFromString(ref index, ref nodeParams);
                    m_blendOpAlpha = (AvailableBlendOps)m_blendOpAlphaInline.IntValue;
                }
                m_blendOpEnabled = (m_blendOpRGB != AvailableBlendOps.OFF);
            }
        }
Exemplo n.º 6
0
        public void ReadFromString(ref uint index, ref string[] nodeParams)
        {
            m_currentRGBIndex = Convert.ToInt32(nodeParams[index++]);
            m_sourceFactorRGB = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), nodeParams[index++]);
            m_destFactorRGB   = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), nodeParams[index++]);

            m_currentAlphaIndex = Convert.ToInt32(nodeParams[index++]);
            m_sourceFactorAlpha = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), nodeParams[index++]);
            m_destFactorAlpha   = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), nodeParams[index++]);

            m_blendOpRGB   = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), nodeParams[index++]);
            m_blendOpAlpha = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), nodeParams[index++]);
        }
Exemplo n.º 7
0
 public static void CreateBlendOp(string blendOpData, ref TemplateBlendData blendDataObj)
 {
     blendDataObj.ValidBlendOp = true;
     // TODO: OPTIMIZE REGEX EXPRESSIONS TO NOT CATCH EMPTY GROUPS
     foreach (Match match in Regex.Matches(blendOpData, BlendOpPattern, RegexOptions.None))
     {
         if (match.Groups.Count == 2)
         {
             try
             {
                 AvailableBlendOps blendOpsAll = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), match.Groups[1].Value);
                 blendDataObj.SeparateBlendOps = false;
                 blendDataObj.BlendOpRGB       = blendOpsAll;
             }
             catch (Exception e)
             {
                 Debug.LogException(e);
                 blendDataObj.DataCheck = TemplateDataCheck.Unreadable;
                 return;
             }
             break;
         }
         else if (match.Groups.Count == 3)
         {
             try
             {
                 AvailableBlendOps blendOpsRGB = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), match.Groups[1].Value);
                 blendDataObj.BlendOpRGB = blendOpsRGB;
                 if (match.Groups[2].Success)
                 {
                     AvailableBlendOps blendOpsA = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), match.Groups[2].Value);
                     blendDataObj.BlendOpAlpha     = blendOpsA;
                     blendDataObj.SeparateBlendOps = true;
                 }
                 else
                 {
                     blendDataObj.SeparateBlendOps = false;
                 }
             }
             catch (Exception e)
             {
                 Debug.LogException(e);
                 blendDataObj.DataCheck = TemplateDataCheck.Unreadable;
                 return;
             }
             break;
         }
     }
 }
Exemplo n.º 8
0
 public void CopyFrom(TemplatesBlendModule other)
 {
     m_validBlendMode    = other.ValidBlendMode;
     m_validBlendOp      = other.ValidBlendOp;
     m_blendModeEnabled  = other.BlendModeEnabled;
     m_currentRGBIndex   = other.CurrentRGBIndex;
     m_sourceFactorRGB   = other.SourceFactorRGB;
     m_destFactorRGB     = other.DestFactorRGB;
     m_currentAlphaIndex = other.CurrentAlphaIndex;
     m_sourceFactorAlpha = other.SourceFactorAlpha;
     m_destFactorAlpha   = other.DestFactorAlpha;
     m_blendOpEnabled    = other.BlendOpEnabled;
     m_blendOpRGB        = other.BlendOpRGB;
     m_blendOpAlpha      = other.BlendOpAlpha;
 }
Exemplo n.º 9
0
		void DrawBlock( UndoParentNode owner, bool style )
		{
			EditorGUI.BeginChangeCheck():
			{
				if( m_blendModeEnabled )
				{
					// RGB
					EditorGUI.BeginChangeCheck():
					m_currentRGBIndex = owner.EditorGUILayoutPopup( BlendModesRGBStr, m_currentRGBIndex, m_commonBlendTypesArr ):
					if( EditorGUI.EndChangeCheck() )
					{
						if( m_currentRGBIndex > 1 )
						{
							m_sourceFactorRGB = m_commonBlendTypes[ m_currentRGBIndex ].SourceFactor:
							m_sourceFactorRGBInline.IntValue = (int)m_sourceFactorRGB:
							m_sourceFactorRGBInline.SetInlineNodeValue():

							m_destFactorRGB = m_commonBlendTypes[ m_currentRGBIndex ].DestFactor:
							m_destFactorRGBInline.IntValue = (int)m_destFactorRGB:
							m_destFactorRGBInline.SetInlineNodeValue():
						}
					}
					EditorGUI.BeginDisabledGroup( m_currentRGBIndex == 0 ):

					EditorGUI.BeginChangeCheck():
					float cached = EditorGUIUtility.labelWidth:
					if( style )
					{
						EditorGUIUtility.labelWidth = 40:
					}
					else
					{
						EditorGUIUtility.labelWidth = 25:
					}

					EditorGUILayout.BeginHorizontal():
					//m_sourceFactorRGB = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup( SourceFactorStr, m_sourceFactorRGB ):
					m_sourceFactorRGBInline.CustomDrawer( ref owner, ( x ) => { m_sourceFactorRGB = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup( SourceFactorStr, m_sourceFactorRGB ): }, SourceFactorStr ):
					if( style )
					{
						EditorGUI.indentLevel--:
						EditorGUIUtility.labelWidth = 25:
					}
					//m_destFactorRGB = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup( DstFactorStr, m_destFactorRGB ):
					m_destFactorRGBInline.CustomDrawer( ref owner, ( x ) => { m_destFactorRGB = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup( DstFactorStr, m_destFactorRGB ): }, DstFactorStr ):
					if( style )
						EditorGUI.indentLevel++:

					EditorGUILayout.EndHorizontal():

					EditorGUIUtility.labelWidth = cached:
					if( EditorGUI.EndChangeCheck() )
					{
						CheckRGBIndex():
					}

					EditorGUI.EndDisabledGroup():
					// Alpha
					EditorGUILayout.Separator():

					EditorGUI.BeginChangeCheck():
					m_currentAlphaIndex = owner.EditorGUILayoutPopup( BlendModesAlphaStr, m_currentAlphaIndex, m_commonBlendTypesArr ):
					if( EditorGUI.EndChangeCheck() )
					{
						if( m_currentAlphaIndex > 0 )
						{
							m_sourceFactorAlpha = m_commonBlendTypes[ m_currentAlphaIndex ].SourceFactor:
							m_sourceFactorAlphaInline.IntValue = (int)m_sourceFactorAlpha:
							m_sourceFactorAlphaInline.SetInlineNodeValue():

							m_destFactorAlpha = m_commonBlendTypes[ m_currentAlphaIndex ].DestFactor:
							m_destFactorAlphaInline.IntValue = (int)m_destFactorAlpha:
							m_destFactorAlphaInline.SetInlineNodeValue():
						}
					}
					EditorGUI.BeginDisabledGroup( m_currentAlphaIndex == 0 ):

					EditorGUI.BeginChangeCheck():
					cached = EditorGUIUtility.labelWidth:
					if( style )
					{
						EditorGUIUtility.labelWidth = 40:
					}
					else
					{
						EditorGUIUtility.labelWidth = 25:
					}
					EditorGUILayout.BeginHorizontal():
					//m_sourceFactorAlpha = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup( SourceFactorStr, m_sourceFactorAlpha ):
					m_sourceFactorAlphaInline.CustomDrawer( ref owner, ( x ) => { m_sourceFactorAlpha = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup( SourceFactorStr, m_sourceFactorAlpha ): }, SourceFactorStr ):
					if( style )
					{
						EditorGUI.indentLevel--:
						EditorGUIUtility.labelWidth = 25:
					}
					//m_destFactorAlpha = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup( DstFactorStr, m_destFactorAlpha ):
					m_destFactorAlphaInline.CustomDrawer( ref owner, ( x ) => { m_destFactorAlpha = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup( DstFactorStr, m_destFactorAlpha ): }, DstFactorStr ):
					if( style )
						EditorGUI.indentLevel++:
					EditorGUILayout.EndHorizontal():
					EditorGUIUtility.labelWidth = cached:

					if( EditorGUI.EndChangeCheck() )
					{
						CheckAlphaIndex():
					}

					EditorGUI.EndDisabledGroup():
					EditorGUILayout.Separator():
				}

				if( m_blendOpEnabled )
				{
					// Both these tests should be removed on a later stage
					// ASE v154dev004 changed AvailableBlendOps.OFF value from -1 to 0
					// If importing the new package into an already opened ASE window makes 
					// hotcode to preserve the -1 value on these variables
					if( (int)m_blendOpRGB == -1 )
						m_blendOpRGB = AvailableBlendOps.OFF:

					if( (int)m_blendOpAlpha == -1 )
						m_blendOpAlpha = AvailableBlendOps.OFF:

					//m_blendOpRGB = (AvailableBlendOps)owner.EditorGUILayoutEnumPopup( BlendOpsRGBStr, m_blendOpRGB ):
					m_blendOpRGBInline.CustomDrawer( ref owner, ( x ) => { m_blendOpRGB = (AvailableBlendOps)x.EditorGUILayoutPopup( BlendOpsRGBStr, (int)m_blendOpRGB, BlendOpsHelper.BlendOpsLabels ): }, BlendOpsRGBStr ):
					EditorGUILayout.Separator():
					//m_blendOpAlpha = (AvailableBlendOps)owner.EditorGUILayoutEnumPopup( BlendOpsAlphaStr, m_blendOpAlpha ):
					m_blendOpAlphaInline.CustomDrawer( ref owner, ( x ) => { m_blendOpAlpha = (AvailableBlendOps)x.EditorGUILayoutPopup( BlendOpsAlphaStr, (int)m_blendOpAlpha, BlendOpsHelper.BlendOpsLabels ): }, BlendOpsAlphaStr ):
				}

				if( m_validAlphaToMask )
				{
					EditorGUILayout.Space():
					m_alphaToMaskValue = owner.EditorGUILayoutToggle( AlphaToMaskStr, m_alphaToMaskValue ):
				}
			}

			if( EditorGUI.EndChangeCheck() )
			{
				m_isDirty = true:
			}
		}
Exemplo n.º 10
0
		public void ConfigureFromTemplateData( TemplateBlendData blendData )
		{
			if( blendData.ValidAlphaToMask )
			{
				if( m_validAlphaToMask != blendData.ValidAlphaToMask )
				{
					m_alphaToMaskValue = blendData.AlphaToMaskValue:
					m_validAlphaToMask = blendData.ValidAlphaToMask:
					m_alphaToMaskIndependent = blendData.IndependentAlphaToMask:
				}
			}

			if( blendData.ValidBlendMode )
			{
				if( m_validBlendMode != blendData.ValidBlendMode )
				{
					m_blendModeEnabled = true:
					m_independentModule = blendData.IndependentModule:
					if( string.IsNullOrEmpty( blendData.SourceFactorRGBInline ) )
					{
						m_sourceFactorRGB = blendData.SourceFactorRGB:
						m_sourceFactorRGBInline.ResetProperty():
					}
					else
					{
						m_sourceFactorRGBInline.SetInlineByName( blendData.SourceFactorRGBInline ):
					}

					if( string.IsNullOrEmpty( blendData.DestFactorRGBInline ) )
					{
						m_destFactorRGB = blendData.DestFactorRGB:
						m_destFactorRGBInline.ResetProperty():
					}
					else
					{
						m_destFactorRGBInline.SetInlineByName( blendData.DestFactorRGBInline ):
					}

					if( string.IsNullOrEmpty( blendData.SourceFactorAlphaInline ) )
					{
						m_sourceFactorAlpha = blendData.SourceFactorAlpha:
						m_sourceFactorAlphaInline.ResetProperty():
					}
					else
					{
						m_sourceFactorAlphaInline.SetInlineByName( blendData.SourceFactorAlphaInline ):
					}
					if( string.IsNullOrEmpty( blendData.DestFactorAlphaInline ) )
					{
						m_destFactorAlpha = blendData.DestFactorAlpha:
						m_destFactorAlphaInline.ResetProperty():
					}
					else
					{
						m_destFactorAlphaInline.SetInlineByName( blendData.DestFactorAlphaInline ):
					}

					if( blendData.SeparateBlendFactors )
					{
						if( blendData.BlendModeOff )
						{
							m_currentRGBIndex = 0:
						}
						else
						{
							CheckRGBIndex():
						}
						CheckAlphaIndex():
					}
					else
					{
						if( blendData.BlendModeOff )
						{
							m_currentRGBIndex = 0:
						}
						else
						{
							CheckRGBIndex():
						}
						m_currentAlphaIndex = 0:
					}
				}
			}
			else
			{
				m_blendModeEnabled = false:
			}

			if( blendData.ValidBlendOp )
			{
				if( m_validBlendOp != blendData.ValidBlendOp )
				{
					m_blendOpEnabled = true:
					if( string.IsNullOrEmpty( blendData.BlendOpRGBInline ) )
					{
						m_blendOpRGB = blendData.BlendOpRGB:
						m_blendOpRGBInline.ResetProperty():
					}
					else
					{
						m_blendOpRGBInline.SetInlineByName( blendData.BlendOpRGBInline ):
					}

					if( string.IsNullOrEmpty( blendData.BlendOpAlphaInline ) )
					{
						m_blendOpAlpha = blendData.BlendOpAlpha:
						m_blendOpAlphaInline.ResetProperty():
					}
					else
					{
						m_blendOpAlphaInline.SetInlineByName( blendData.BlendOpAlphaInline ):
					}
				}
			}
			else
			{
				m_blendOpEnabled = false:
			}

			m_validBlendMode = blendData.ValidBlendMode:
			m_validBlendOp = blendData.ValidBlendOp:
			m_validData = m_validBlendMode || m_validBlendOp:
		}
Exemplo n.º 11
0
        public void Draw(UndoParentNode owner, bool customBlendAvailable)
        {
            m_enabled = customBlendAvailable;

            // RGB
            EditorGUI.BeginChangeCheck();
            m_currentIndex = owner.EditorGUILayoutPopup(BlendModesRGBStr, m_currentIndex, m_commonBlendTypesArr);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_currentIndex > 1)
                {
                    m_sourceFactorRGB = m_commonBlendTypes[m_currentIndex].SourceFactor;
                    m_destFactorRGB   = m_commonBlendTypes[m_currentIndex].DestFactor;
                }
            }
            EditorGUI.BeginDisabledGroup(m_currentIndex == 0);

            EditorGUI.BeginChangeCheck();
            float cached = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 40;

            EditorGUILayout.BeginHorizontal();
            m_sourceFactorRGB = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(SourceFactorStr, m_sourceFactorRGB);
            EditorGUI.indentLevel--;
            EditorGUIUtility.labelWidth = 25;
            m_destFactorRGB             = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(DstFactorStr, m_destFactorRGB);
            EditorGUI.indentLevel++;
            EditorGUILayout.EndHorizontal();

            EditorGUIUtility.labelWidth = cached;
            if (EditorGUI.EndChangeCheck())
            {
                CheckRGBIndex();
            }

            EditorGUI.BeginChangeCheck();
            m_blendOpRGB = (AvailableBlendOps)owner.EditorGUILayoutEnumPopup(BlendOpsRGBStr, m_blendOpRGB);
            if (EditorGUI.EndChangeCheck())
            {
                m_blendOpEnabled = m_blendOpRGB != AvailableBlendOps.OFF;
            }

            EditorGUI.EndDisabledGroup();

            //if ( m_currentIndex == 0 )
            //	m_currentAlphaIndex = 0;

            //if ( m_blendOpRGB == AvailableBlendOps.OFF )
            //	m_blendOpAlpha = AvailableBlendOps.OFF;

            // Alpha
            EditorGUILayout.Separator();

            //EditorGUI.BeginDisabledGroup( m_currentAlphaIndex == 0 );
            EditorGUI.BeginChangeCheck();
            m_currentAlphaIndex = owner.EditorGUILayoutPopup(BlendModesAlphaStr, m_currentAlphaIndex, m_commonBlendTypesArr);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_currentAlphaIndex > 0)
                {
                    m_sourceFactorAlpha = m_commonBlendTypes[m_currentAlphaIndex].SourceFactor;
                    m_destFactorAlpha   = m_commonBlendTypes[m_currentAlphaIndex].DestFactor;
                }
            }
            //EditorGUI.EndDisabledGroup();
            EditorGUI.BeginDisabledGroup(m_currentAlphaIndex == 0);
            //EditorGUI.BeginDisabledGroup( m_currentAlphaIndex == 0 );

            EditorGUI.BeginChangeCheck();
            cached = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth = 40;
            EditorGUILayout.BeginHorizontal();
            m_sourceFactorAlpha = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(SourceFactorStr, m_sourceFactorAlpha);
            EditorGUI.indentLevel--;
            EditorGUIUtility.labelWidth = 25;
            m_destFactorAlpha           = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(DstFactorStr, m_destFactorAlpha);
            EditorGUI.indentLevel++;
            EditorGUILayout.EndHorizontal();
            EditorGUIUtility.labelWidth = cached;

            if (EditorGUI.EndChangeCheck())
            {
                CheckAlphaIndex();
            }
            m_blendOpAlpha = (AvailableBlendOps)owner.EditorGUILayoutEnumPopup(BlendOpsAlphaStr, m_blendOpAlpha);
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Separator();
        }
        public void ConfigureFromTemplateData(TemplateBlendData blendData)
        {
            if (blendData.ValidBlendMode)
            {
                if (m_validBlendMode != blendData.ValidBlendMode)
                {
                    m_blendModeEnabled  = true;
                    m_independentModule = blendData.IndependentModule;
                    if (string.IsNullOrEmpty(blendData.SourceFactorRGBInline))
                    {
                        m_sourceFactorRGB = blendData.SourceFactorRGB;
                        m_sourceFactorRGBInline.ResetProperty();
                    }
                    else
                    {
                        m_sourceFactorRGBInline.SetInlineByName(blendData.SourceFactorRGBInline);
                    }

                    if (string.IsNullOrEmpty(blendData.DestFactorRGBInline))
                    {
                        m_destFactorRGB = blendData.DestFactorRGB;
                        m_destFactorRGBInline.ResetProperty();
                    }
                    else
                    {
                        m_destFactorRGBInline.SetInlineByName(blendData.DestFactorRGBInline);
                    }

                    if (string.IsNullOrEmpty(blendData.SourceFactorAlphaInline))
                    {
                        m_sourceFactorAlpha = blendData.SourceFactorAlpha;
                        m_sourceFactorAlphaInline.ResetProperty();
                    }
                    else
                    {
                        m_sourceFactorAlphaInline.SetInlineByName(blendData.SourceFactorAlphaInline);
                    }
                    if (string.IsNullOrEmpty(blendData.DestFactorAlphaInline))
                    {
                        m_destFactorAlpha = blendData.DestFactorAlpha;
                        m_destFactorAlphaInline.ResetProperty();
                    }
                    else
                    {
                        m_destFactorAlphaInline.SetInlineByName(blendData.DestFactorAlphaInline);
                    }

                    if (blendData.SeparateBlendFactors)
                    {
                        if (blendData.BlendModeOff)
                        {
                            m_currentRGBIndex = 0;
                        }
                        else
                        {
                            CheckRGBIndex();
                        }
                        CheckAlphaIndex();
                    }
                    else
                    {
                        if (blendData.BlendModeOff)
                        {
                            m_currentRGBIndex = 0;
                        }
                        else
                        {
                            CheckRGBIndex();
                        }
                        m_currentAlphaIndex = 0;
                    }
                }
            }
            else
            {
                m_blendModeEnabled = false;
            }

            if (blendData.ValidBlendOp)
            {
                if (m_validBlendOp != blendData.ValidBlendOp)
                {
                    m_blendOpEnabled = true;
                    if (string.IsNullOrEmpty(blendData.BlendOpRGBInline))
                    {
                        m_blendOpRGB = blendData.BlendOpRGB;
                        m_blendOpRGBInline.ResetProperty();
                    }
                    else
                    {
                        m_blendOpRGBInline.SetInlineByName(blendData.BlendOpRGBInline);
                    }

                    if (string.IsNullOrEmpty(blendData.BlendOpAlphaInline))
                    {
                        m_blendOpAlpha = blendData.BlendOpAlpha;
                        m_blendOpAlphaInline.ResetProperty();
                    }
                    else
                    {
                        m_blendOpAlphaInline.SetInlineByName(blendData.BlendOpAlphaInline);
                    }
                }
            }
            else
            {
                m_blendOpEnabled = false;
            }

            m_target         = blendData.Target;
            m_validBlendMode = blendData.ValidBlendMode;
            m_validBlendOp   = blendData.ValidBlendOp;
            m_validData      = m_validBlendMode || m_validBlendOp;
        }
Exemplo n.º 13
0
        void DrawBlock(ParentNode owner, bool style)
        {
            EditorGUI.BeginChangeCheck();
            {
                if (m_blendModeEnabled)
                {
                    // RGB
                    EditorGUI.BeginChangeCheck();
                    m_currentRGBIndex = owner.EditorGUILayoutPopup(BlendModesRGBStr, m_currentRGBIndex, m_commonBlendTypesArr);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (m_currentRGBIndex > 1)
                        {
                            m_sourceFactorRGB = m_commonBlendTypes[m_currentRGBIndex].SourceFactor;
                            m_destFactorRGB   = m_commonBlendTypes[m_currentRGBIndex].DestFactor;
                        }
                    }
                    EditorGUI.BeginDisabledGroup(m_currentRGBIndex == 0);

                    EditorGUI.BeginChangeCheck();
                    float cached = EditorGUIUtility.labelWidth;
                    if (style)
                    {
                        EditorGUIUtility.labelWidth = 40;
                    }
                    else
                    {
                        EditorGUIUtility.labelWidth = 25;
                    }

                    EditorGUILayout.BeginHorizontal();
                    m_sourceFactorRGB = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(SourceFactorStr, m_sourceFactorRGB);
                    if (style)
                    {
                        EditorGUI.indentLevel--;
                        EditorGUIUtility.labelWidth = 25;
                    }
                    m_destFactorRGB = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(DstFactorStr, m_destFactorRGB);
                    if (style)
                    {
                        EditorGUI.indentLevel++;
                    }

                    EditorGUILayout.EndHorizontal();

                    EditorGUIUtility.labelWidth = cached;
                    if (EditorGUI.EndChangeCheck())
                    {
                        CheckRGBIndex();
                    }

                    EditorGUI.EndDisabledGroup();
                    // Alpha
                    EditorGUILayout.Separator();

                    EditorGUI.BeginChangeCheck();
                    m_currentAlphaIndex = owner.EditorGUILayoutPopup(BlendModesAlphaStr, m_currentAlphaIndex, m_commonBlendTypesArr);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (m_currentAlphaIndex > 0)
                        {
                            m_sourceFactorAlpha = m_commonBlendTypes[m_currentAlphaIndex].SourceFactor;
                            m_destFactorAlpha   = m_commonBlendTypes[m_currentAlphaIndex].DestFactor;
                        }
                    }
                    EditorGUI.BeginDisabledGroup(m_currentAlphaIndex == 0);

                    EditorGUI.BeginChangeCheck();
                    cached = EditorGUIUtility.labelWidth;
                    if (style)
                    {
                        EditorGUIUtility.labelWidth = 40;
                    }
                    else
                    {
                        EditorGUIUtility.labelWidth = 25;
                    }
                    EditorGUILayout.BeginHorizontal();
                    m_sourceFactorAlpha = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(SourceFactorStr, m_sourceFactorAlpha);
                    if (style)
                    {
                        EditorGUI.indentLevel--;
                        EditorGUIUtility.labelWidth = 25;
                    }
                    m_destFactorAlpha = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(DstFactorStr, m_destFactorAlpha);
                    if (style)
                    {
                        EditorGUI.indentLevel++;
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUIUtility.labelWidth = cached;

                    if (EditorGUI.EndChangeCheck())
                    {
                        CheckAlphaIndex();
                    }

                    EditorGUI.EndDisabledGroup();
                    EditorGUILayout.Separator();
                }

                if (m_blendOpEnabled)
                {
                    m_blendOpRGB = (AvailableBlendOps)owner.EditorGUILayoutEnumPopup(BlendOpsRGBStr, m_blendOpRGB);
                    EditorGUILayout.Separator();
                    m_blendOpAlpha = (AvailableBlendOps)owner.EditorGUILayoutEnumPopup(BlendOpsAlphaStr, m_blendOpAlpha);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                m_isDirty = true;
            }
        }
Exemplo n.º 14
0
 public void ReadBlendOpFromString(ref uint index, ref string[] nodeParams)
 {
     m_blendOpRGB     = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), nodeParams[index++]);
     m_blendOpAlpha   = (AvailableBlendOps)Enum.Parse(typeof(AvailableBlendOps), nodeParams[index++]);
     m_blendOpEnabled = (m_blendOpRGB != AvailableBlendOps.OFF);
 }
Exemplo n.º 15
0
        public override void Draw(ParentNode owner)
        {
            bool blendModeIsVisible = EditorVariablesManager.ExpandedBlendModeModule.Value;

            NodeUtils.DrawPropertyGroup(ref blendModeIsVisible, BlendModeStr, () =>
            {
                if (m_blendModeEnabled)
                {
                    // RGB
                    EditorGUI.BeginChangeCheck();
                    m_currentRGBIndex = owner.EditorGUILayoutPopup(BlendModesRGBStr, m_currentRGBIndex, m_commonBlendTypesArr);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (m_currentRGBIndex > 1)
                        {
                            m_sourceFactorRGB = m_commonBlendTypes[m_currentRGBIndex].SourceFactor;
                            m_destFactorRGB   = m_commonBlendTypes[m_currentRGBIndex].DestFactor;
                        }
                    }
                    EditorGUI.BeginDisabledGroup(m_currentRGBIndex == 0);

                    EditorGUI.BeginChangeCheck();
                    float cached = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 40;

                    EditorGUILayout.BeginHorizontal();
                    m_sourceFactorRGB = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(SourceFactorStr, m_sourceFactorRGB);
                    EditorGUI.indentLevel--;
                    EditorGUIUtility.labelWidth = 25;
                    m_destFactorRGB             = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(DstFactorStr, m_destFactorRGB);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.EndHorizontal();

                    EditorGUIUtility.labelWidth = cached;
                    if (EditorGUI.EndChangeCheck())
                    {
                        CheckRGBIndex();
                    }

                    EditorGUI.EndDisabledGroup();
                    // Alpha
                    EditorGUILayout.Separator();

                    EditorGUI.BeginChangeCheck();
                    m_currentAlphaIndex = owner.EditorGUILayoutPopup(BlendModesAlphaStr, m_currentAlphaIndex, m_commonBlendTypesArr);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (m_currentAlphaIndex > 0)
                        {
                            m_sourceFactorAlpha = m_commonBlendTypes[m_currentAlphaIndex].SourceFactor;
                            m_destFactorAlpha   = m_commonBlendTypes[m_currentAlphaIndex].DestFactor;
                        }
                    }
                    EditorGUI.BeginDisabledGroup(m_currentAlphaIndex == 0);

                    EditorGUI.BeginChangeCheck();
                    cached = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 40;
                    EditorGUILayout.BeginHorizontal();
                    m_sourceFactorAlpha = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(SourceFactorStr, m_sourceFactorAlpha);
                    EditorGUI.indentLevel--;
                    EditorGUIUtility.labelWidth = 25;
                    m_destFactorAlpha           = (AvailableBlendFactor)owner.EditorGUILayoutEnumPopup(DstFactorStr, m_destFactorAlpha);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.EndHorizontal();
                    EditorGUIUtility.labelWidth = cached;

                    if (EditorGUI.EndChangeCheck())
                    {
                        CheckAlphaIndex();
                    }

                    EditorGUI.EndDisabledGroup();
                    EditorGUILayout.Separator();
                }

                if (m_blendOpEnabled)
                {
                    m_blendOpRGB = (AvailableBlendOps)owner.EditorGUILayoutEnumPopup(BlendOpsRGBStr, m_blendOpRGB);
                    EditorGUILayout.Separator();
                    m_blendOpAlpha = (AvailableBlendOps)owner.EditorGUILayoutEnumPopup(BlendOpsAlphaStr, m_blendOpAlpha);
                }
            });

            EditorVariablesManager.ExpandedBlendModeModule.Value = blendModeIsVisible;
        }
Exemplo n.º 16
0
        public void Draw(UndoParentNode owner, bool customBlendAvailable)
        {
            m_enabled = customBlendAvailable;

            // RGB
            EditorGUI.BeginChangeCheck();
            m_currentIndex = owner.EditorGUILayoutPopup(BlendModesRGBStr, m_currentIndex, m_commonBlendTypesArr);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_currentIndex > 1)
                {
                    m_sourceFactorRGB.IntValue = (int)m_commonBlendTypes[m_currentIndex].SourceFactor;
                    m_sourceFactorRGB.SetInlineNodeValue();

                    m_destFactorRGB.IntValue = (int)m_commonBlendTypes[m_currentIndex].DestFactor;
                    m_destFactorRGB.SetInlineNodeValue();
                }
            }
            EditorGUI.BeginDisabledGroup(m_currentIndex == 0);

            EditorGUI.BeginChangeCheck();
            float cached = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 40;

            EditorGUILayout.BeginHorizontal();
            AvailableBlendFactor tempCast = (AvailableBlendFactor)m_sourceFactorRGB.IntValue;

            m_sourceFactorRGB.CustomDrawer(ref owner, (x) => { tempCast = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup(SourceFactorStr, tempCast); }, SourceFactorStr);
            m_sourceFactorRGB.IntValue = (int)tempCast;
            EditorGUI.indentLevel--;
            EditorGUIUtility.labelWidth = 25;
            tempCast = (AvailableBlendFactor)m_destFactorRGB.IntValue;
            m_destFactorRGB.CustomDrawer(ref owner, (x) => { tempCast = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup(DstFactorStr, tempCast); }, DstFactorStr);
            m_destFactorRGB.IntValue = (int)tempCast;
            EditorGUI.indentLevel++;
            EditorGUILayout.EndHorizontal();

            EditorGUIUtility.labelWidth = cached;
            if (EditorGUI.EndChangeCheck())
            {
                CheckRGBIndex();
            }

            EditorGUI.BeginChangeCheck();
            AvailableBlendOps tempOpCast = (AvailableBlendOps)m_blendOpRGB.IntValue;

            m_blendOpRGB.CustomDrawer(ref owner, (x) => { tempOpCast = (AvailableBlendOps)x.EditorGUILayoutEnumPopup(BlendOpsRGBStr, tempOpCast); }, BlendOpsRGBStr);
            m_blendOpRGB.IntValue = (int)tempOpCast;
            if (EditorGUI.EndChangeCheck())
            {
                m_blendOpEnabled = (!m_blendOpRGB.Active && m_blendOpRGB.IntValue > -1) || (m_blendOpRGB.Active && m_blendOpRGB.NodeId > -1);                    //AvailableBlendOps.OFF;
                m_blendOpRGB.SetInlineNodeValue();
            }

            EditorGUI.EndDisabledGroup();

            // Alpha
            EditorGUILayout.Separator();

            EditorGUI.BeginChangeCheck();
            m_currentAlphaIndex = owner.EditorGUILayoutPopup(BlendModesAlphaStr, m_currentAlphaIndex, m_commonBlendTypesArr);
            if (EditorGUI.EndChangeCheck())
            {
                if (m_currentAlphaIndex > 0)
                {
                    m_sourceFactorAlpha.IntValue = (int)m_commonBlendTypes[m_currentAlphaIndex].SourceFactor;
                    m_sourceFactorAlpha.SetInlineNodeValue();

                    m_destFactorAlpha.IntValue = (int)m_commonBlendTypes[m_currentAlphaIndex].DestFactor;
                    m_destFactorAlpha.SetInlineNodeValue();
                }
            }
            EditorGUI.BeginDisabledGroup(m_currentAlphaIndex == 0);

            EditorGUI.BeginChangeCheck();
            cached = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth = 40;
            EditorGUILayout.BeginHorizontal();
            tempCast = (AvailableBlendFactor)m_sourceFactorAlpha.IntValue;
            m_sourceFactorAlpha.CustomDrawer(ref owner, (x) => { tempCast = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup(SourceFactorStr, tempCast); }, SourceFactorStr);
            m_sourceFactorAlpha.IntValue = (int)tempCast;
            EditorGUI.indentLevel--;
            EditorGUIUtility.labelWidth = 25;
            tempCast = (AvailableBlendFactor)m_destFactorAlpha.IntValue;
            m_destFactorAlpha.CustomDrawer(ref owner, (x) => { tempCast = (AvailableBlendFactor)x.EditorGUILayoutEnumPopup(DstFactorStr, tempCast); }, DstFactorStr);
            m_destFactorAlpha.IntValue = (int)tempCast;
            EditorGUI.indentLevel++;
            EditorGUILayout.EndHorizontal();
            EditorGUIUtility.labelWidth = cached;

            if (EditorGUI.EndChangeCheck())
            {
                CheckAlphaIndex();
            }
            EditorGUI.BeginChangeCheck();
            tempOpCast = (AvailableBlendOps)m_blendOpAlpha.IntValue;
            m_blendOpAlpha.CustomDrawer(ref owner, (x) => { tempOpCast = (AvailableBlendOps)x.EditorGUILayoutEnumPopup(BlendOpsAlphaStr, tempOpCast); }, BlendOpsAlphaStr);
            m_blendOpAlpha.IntValue = (int)tempOpCast;
            if (EditorGUI.EndChangeCheck())
            {
                m_blendOpAlpha.SetInlineNodeValue();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Separator();
        }