private void GetMaterialProperties(Material material) { color = material.GetColor(shaderProperties.colorID); sourceColorBlendMode = (BlendMode)material.GetInt(shaderProperties.sourceColorBlendModeID); destinationColorBlendMode = (BlendMode)material.GetInt(shaderProperties.destinationColorBlendModeID); sourceAlphaBlendMode = (BlendMode)material.GetInt(shaderProperties.sourceAlphaBlendModeID); destinationAlphaBlendMode = (BlendMode)material.GetInt(shaderProperties.destinationAlphaBlendModeID); cullMode = (CullMode)material.GetInt(shaderProperties.cullModeID); zWriteMode = (ZWriteMode)material.GetInt(shaderProperties.zWriteModeID); zTestMode = (ZTestMode)material.GetInt(shaderProperties.zTestModeID); depthOffsetFactor = material.GetFloat(shaderProperties.depthOffsetFactorID); depthOffsetUnits = material.GetFloat(shaderProperties.depthOffsetUnitsID); blendOpColor = (BlendOp)material.GetInt(shaderProperties.blendOpColorID); blendOpAlpha = (BlendOp)material.GetInt(shaderProperties.blendOpAlphaID); }
public override void ReadFromString(ref string[] nodeParams) { try { base.ReadFromString(ref nodeParams); m_currentLightModel = ( StandardShaderLightModel )Enum.Parse(typeof(StandardShaderLightModel), GetCurrentParam(ref nodeParams)); //_isHidden = Convert.ToBoolean( GetCurrentParam( ref nodeParams ) ); //_shaderCategory = GetCurrentParam( ref nodeParams ); //if ( _shaderCategory.Length > 0 ) // _shaderCategory = UIUtils.RemoveInvalidCharacters( _shaderCategory ); ShaderName = GetCurrentParam(ref nodeParams); if (m_shaderName.Length > 0) { ShaderName = UIUtils.RemoveShaderInvalidCharacters(ShaderName); } //_materialName = GetCurrentParam( ref nodeParams ); //_currentMaterial = AssetDatabase.LoadAssetAtPath<Material>( _materialName ); for (int i = 0; i < m_codeGenerationDataList.Count; i++) { m_codeGenerationDataList[i].IsActive = Convert.ToBoolean(GetCurrentParam(ref nodeParams)); } m_cullMode = ( CullMode )Enum.Parse(typeof(CullMode), GetCurrentParam(ref nodeParams)); m_zWriteMode = ( ZWriteMode )Enum.Parse(typeof(ZWriteMode), GetCurrentParam(ref nodeParams)); m_zTestMode = ( ZTestMode )Enum.Parse(typeof(ZTestMode), GetCurrentParam(ref nodeParams)); m_alphaMode = ( AlphaMode )Enum.Parse(typeof(AlphaMode), GetCurrentParam(ref nodeParams)); m_opacityMaskClipValue = Convert.ToSingle(GetCurrentParam(ref nodeParams)); m_keepAlpha = Convert.ToBoolean(GetCurrentParam(ref nodeParams)); m_castShadows = Convert.ToBoolean(GetCurrentParam(ref nodeParams)); m_queueOrder = Convert.ToInt32(GetCurrentParam(ref nodeParams)); if (UIUtils.CurrentShaderVersion() > 11) { m_customBlendMode = Convert.ToBoolean(GetCurrentParam(ref nodeParams)); m_renderType = ( RenderType )Enum.Parse(typeof(RenderType), GetCurrentParam(ref nodeParams)); m_renderQueue = ( RenderQueue )Enum.Parse(typeof(RenderQueue), GetCurrentParam(ref nodeParams)); } m_lastLightModel = m_currentLightModel; DeleteAllInputConnections(true); AddMasterPorts(); m_customBlendMode = TestCustomBlendMode(); } catch (Exception e) { Debug.Log(e); } }
private void ExposeMaterialProperties() { // Create a style for the titles GUIStyle guiStyle = new GUIStyle(); guiStyle.fontStyle = FontStyle.Bold; guiStyle.normal.textColor = Color.white; // Start the check if anything has changed... EditorGUI.BeginChangeCheck(); // Show the properties EditorGUILayout.LabelField("Main texture and color", guiStyle); //TexturePropertySingleLine(new GUIContent(ShaderProperties.MAIN_TEXTURE_DESCRIPTION), GetMaterialProperties(targets)[0]); TextureProperty(GetMaterialProperties(targets)[0], ShaderProperties.MAIN_TEXTURE_DESCRIPTION); color = EditorGUILayout.ColorField(ShaderProperties.COLOR_DESCRIPTION, color); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Color Blending", guiStyle); sourceColorBlendMode = (BlendMode)EditorGUILayout.EnumPopup(ShaderProperties.SOURCE_COLOR_BLEND_MODE_DESCRIPTION, sourceColorBlendMode); destinationColorBlendMode = (BlendMode)EditorGUILayout.EnumPopup(ShaderProperties.DESTINATION_COLOR_BLEND_MODE_DESCRIPTION, destinationColorBlendMode); blendOpColor = (BlendOp)EditorGUILayout.EnumPopup(ShaderProperties.BLEND_OP_COLOR_DESCRIPTION, blendOpColor); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Alpha Blending", guiStyle); sourceAlphaBlendMode = (BlendMode)EditorGUILayout.EnumPopup(ShaderProperties.SOURCE_ALPHA_BLEND_MODE_DESCRIPTION, sourceAlphaBlendMode); destinationAlphaBlendMode = (BlendMode)EditorGUILayout.EnumPopup(ShaderProperties.DESTINATION_ALPHA_BLEND_MODE_DESCRIPTION, destinationAlphaBlendMode); blendOpAlpha = (BlendOp)EditorGUILayout.EnumPopup(ShaderProperties.BLEND_OP_ALPHA_DESCRIPTION, blendOpAlpha); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Culling", guiStyle); cullMode = (CullMode)EditorGUILayout.EnumPopup(ShaderProperties.CULL_MODE_DESCRIPTION, cullMode); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Z Write/Test/Depth", guiStyle); zWriteMode = (ZWriteMode)EditorGUILayout.EnumPopup(ShaderProperties.Z_WRITE_MODE_DESCRIPTION, zWriteMode); zTestMode = (ZTestMode)EditorGUILayout.EnumPopup(ShaderProperties.Z_TEST_MODE_DESCRIPTION, zTestMode); depthOffsetFactor = EditorGUILayout.FloatField(ShaderProperties.DEPTH_OFFSET_FACTOR_DESCRIPTION, depthOffsetFactor); depthOffsetUnits = EditorGUILayout.FloatField(ShaderProperties.DEPTH_OFFSET_UNITS_DESCRIPTION, depthOffsetUnits); }