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 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; }
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; }
public static void CreateBlendMode(string blendModeData, ref TemplateBlendData blendDataObj) { blendDataObj.ValidBlendMode = true; // TODO: OPTIMIZE REGEX EXPRESSIONS TO NOT CATCH EMPTY GROUPS foreach (Match match in Regex.Matches(blendModeData, BlendModePattern)) { if (match.Groups.Count == 3) { try { AvailableBlendFactor sourceAll = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), match.Groups[1].Value); AvailableBlendFactor destAll = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), match.Groups[2].Value); blendDataObj.SeparateBlendFactors = false; blendDataObj.SourceFactorRGB = sourceAll; blendDataObj.DestFactorRGB = destAll; } catch (Exception e) { Debug.LogException(e); blendDataObj.DataCheck = TemplateDataCheck.Unreadable; return; } break; } else if (match.Groups.Count == 5) { try { AvailableBlendFactor sourceRGB = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), match.Groups[1].Value); blendDataObj.SourceFactorRGB = sourceRGB; AvailableBlendFactor destRGB = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), match.Groups[2].Value); blendDataObj.DestFactorRGB = destRGB; if (match.Groups[3].Success && match.Groups[4].Success) { AvailableBlendFactor sourceA = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), match.Groups[3].Value); blendDataObj.SourceFactorAlpha = sourceA; AvailableBlendFactor destA = (AvailableBlendFactor)Enum.Parse(typeof(AvailableBlendFactor), match.Groups[4].Value); blendDataObj.DestFactorAlpha = destA; blendDataObj.SeparateBlendFactors = true; } else { blendDataObj.SeparateBlendFactors = false; } } catch (Exception e) { Debug.LogException(e); blendDataObj.DataCheck = TemplateDataCheck.Unreadable; return; } break; } } }
public void ReadBlendModeFromString(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++]); }
public void ReadFromString(ref uint index, ref string[] nodeParams) { m_currentIndex = 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++]); m_enabled = (m_currentIndex > 0 || m_currentAlphaIndex > 0); m_blendOpEnabled = (m_blendOpRGB != AvailableBlendOps.OFF); }
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; }
public void ReadBlendModeFromString(ref uint index, ref string[] nodeParams) { bool validDataOnMeta = m_validBlendMode; if (UIUtils.CurrentShaderVersion() > TemplatesManager.MPShaderVersion) { validDataOnMeta = Convert.ToBoolean(nodeParams[index++]); } if (validDataOnMeta) { 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++]); } }
public void SetBlendOpsFromBlendMode(AlphaMode mode) { switch (mode) { case AlphaMode.Transparent: m_currentIndex = 2; m_sourceFactorRGB = m_commonBlendTypes[m_currentIndex].SourceFactor; m_destFactorRGB = m_commonBlendTypes[m_currentIndex].DestFactor; break; case AlphaMode.Masked: case AlphaMode.Translucent: m_currentIndex = 0; break; case AlphaMode.Premultiply: m_currentIndex = 3; m_sourceFactorRGB = m_commonBlendTypes[m_currentIndex].SourceFactor; m_destFactorRGB = m_commonBlendTypes[m_currentIndex].DestFactor; break; } }
public CommonBlendTypes(string name, AvailableBlendFactor sourceFactor, AvailableBlendFactor destFactor) { Name = name; SourceFactor = sourceFactor; DestFactor = destFactor; }
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(); }
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; } }
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; }
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(); } // 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 (m_blendOpRGB.FloatValue < 0) { m_blendOpRGB.FloatValue = 0; } if (m_blendOpAlpha.FloatValue < 0) { m_blendOpAlpha.FloatValue = 0; } EditorGUI.BeginChangeCheck(); //AvailableBlendOps tempOpCast = (AvailableBlendOps)m_blendOpRGB.IntValue; m_blendOpRGB.CustomDrawer(ref owner, (x) => { m_blendOpRGB.IntValue = x.EditorGUILayoutPopup(BlendOpsRGBStr, m_blendOpRGB.IntValue, BlendOpsLabels); }, 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) => { m_blendOpAlpha.IntValue = x.EditorGUILayoutPopup(BlendOpsAlphaStr, m_blendOpAlpha.IntValue, BlendOpsLabels); }, BlendOpsAlphaStr); //m_blendOpAlpha.IntValue = (int)tempOpCast; if (EditorGUI.EndChangeCheck()) { m_blendOpAlpha.SetInlineNodeValue(); } EditorGUI.EndDisabledGroup(); EditorGUILayout.Separator(); }
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: }
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; }
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: } }
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(); }