//private CustomMaterialEditor _materialEditor; //private GUIStyle _materialLabelStyle; protected override void CommonInit(int uniqueId) { _shaderTypeLabel += "Surface Shader"; m_currentLightModel = m_lastLightModel = StandardShaderLightModel.Standard; //_materialEditor = null; m_codeGenerationDataList = new List <CodeGenerationData>(); m_codeGenerationDataList.Add(new CodeGenerationData("Exclude Deferred", "exclude_path:deferred")); m_codeGenerationDataList.Add(new CodeGenerationData("Exclude Forward", "exclude_path:forward")); m_codeGenerationDataList.Add(new CodeGenerationData("Exclude Legacy Deferred", "exclude_path:prepass")); m_codeGenerationDataList.Add(new CodeGenerationData("Disable shadows", "noshadow")); m_codeGenerationDataList.Add(new CodeGenerationData("Disable Ambient Light", "noambient")); m_codeGenerationDataList.Add(new CodeGenerationData("Disable Per Vertex Light", "novertexlights ")); m_codeGenerationDataList.Add(new CodeGenerationData("Disable all lightmaps", "nolightmap ")); m_codeGenerationDataList.Add(new CodeGenerationData("Disable dynamic global GI", "nodynlightmap")); m_codeGenerationDataList.Add(new CodeGenerationData("Disable directional lightmaps", "nodirlightmap ")); m_codeGenerationDataList.Add(new CodeGenerationData("Disable built-in fog", "nofog")); m_codeGenerationDataList.Add(new CodeGenerationData("Don't generate meta", "nometa")); m_codeGenerationDataList.Add(new CodeGenerationData("Disable Add Pass", "noforwardadd ")); m_textLabelWidth = 97; base.CommonInit(uniqueId); m_shaderNameContent = new GUIContent(ShaderNameStr, string.Empty); }
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); } }
public override void DrawProperties() { base.DrawProperties(); m_buttonStyle.fixedWidth = 200; m_buttonStyle.fixedHeight = 50; //if ( _lightModelLen < 0 ) //{ // _lightModelLen = GUI.skin.label.CalcSize( new GUIContent( _lightModelStr ) ).x; // _cullModeLen = GUI.skin.label.CalcSize( new GUIContent( _cullModeStr ) ).x; // _zWriteModeLen = GUI.skin.label.CalcSize( new GUIContent( _zWriteModeStr ) ).x; // _zTestModeLen = GUI.skin.label.CalcSize( new GUIContent( _zTestModeStr ) ).x; // _shaderNameLen = GUI.skin.label.CalcSize( new GUIContent( _shaderNameStr ) ).x; // //_materialLen = GUI.skin.label.CalcSize( new GUIContent( _materialStr ) ).x; // //_currentShaderLen = GUI.skin.label.CalcSize( new GUIContent( _currentShaderStr ) ).x; //} //float labelWidth = EditorGUIUtility.labelWidth; //EditorGUIUtility.labelWidth = _shaderNameLen; EditorGUILayout.BeginVertical(); { EditorGUILayout.Separator(); //GUI.SetNextControlName( _shaderNameTextfieldControlName ); // Give a name to the textfield control so we can know when the player is typing on it EditorGUI.BeginChangeCheck(); string newShaderName = EditorGUILayout.TextField(m_shaderNameContent, m_shaderName, m_textfieldStyle); //if ( Event.current.isKey && GUI.GetNameOfFocusedControl().Equals( _shaderNameTextfieldControlName ) ) //if player is typing on this specific textfield if (EditorGUI.EndChangeCheck()) { if (newShaderName.Length > 0) { newShaderName = UIUtils.RemoveShaderInvalidCharacters(newShaderName); } else { newShaderName = DefaultShaderName; } ShaderName = newShaderName; } m_shaderNameContent.tooltip = m_shaderName; //EditorGUILayout.Separator(); //EditorGUIUtility.labelWidth = _currentShaderLen; //EditorGUI.BeginChangeCheck(); //_currentShader = EditorGUILayout.ObjectField( _currentShaderStr, _currentShader, typeof( Shader ), false ) as Shader; //if ( EditorGUI.EndChangeCheck() ) //{ // if ( _currentShader != null ) // { // UIUtils.CurrentWindow.OnValidShaderFound( _currentShader, null ); // } //} EditorGUILayout.Separator(); //EditorGUIUtility.labelWidth = _lightModelLen; m_currentLightModel = ( StandardShaderLightModel )EditorGUILayout.EnumPopup(LightModelStr, m_currentLightModel); EditorGUILayout.Separator(); //EditorGUIUtility.labelWidth = _cullModeLen; m_cullMode = ( CullMode )EditorGUILayout.EnumPopup(CullModeStr, m_cullMode); //EditorGUILayout.Separator(); //_zWriteMode = ( eZWriteMode ) EditorGUILayout.EnumPopup( _zWriteModeStr, _zWriteMode ); //EditorGUILayout.Separator(); //_zTestMode = ( eZTestMode ) EditorGUILayout.Popup( _zTestModeStr, ( int ) _zTestMode, ZTestModeStr ); EditorGUILayout.Separator(); EditorGUI.BeginChangeCheck(); m_alphaMode = ( AlphaMode )EditorGUILayout.EnumPopup(AlphaModeStr, m_alphaMode); if (EditorGUI.EndChangeCheck()) { m_customBlendMode = false; UpdateFromBlendMode(); } EditorGUILayout.Separator(); EditorGUI.BeginChangeCheck(); m_renderType = ( RenderType )EditorGUILayout.EnumPopup(RenderTypeStr, m_renderType); EditorGUILayout.Separator(); m_renderQueue = ( RenderQueue )EditorGUILayout.EnumPopup(RenderQueueStr, m_renderQueue); if (EditorGUI.EndChangeCheck()) { m_customBlendMode = true; } EditorGUILayout.Separator(); int queueOrder = EditorGUILayout.IntField(QueueIndexStr, m_queueOrder); m_queueOrder = (queueOrder < 0) ? 0 : queueOrder; bool bufferedEnabled = GUI.enabled; GUI.enabled = (m_alphaMode == AlphaMode.Masked && !m_customBlendMode); m_inputPorts[m_discardPortId].Locked = !GUI.enabled; EditorGUILayout.Separator(); m_opacityMaskClipValue = EditorGUILayout.FloatField(OpacityMaskClipValueStr, m_opacityMaskClipValue); GUI.enabled = bufferedEnabled; EditorGUILayout.Separator(); m_keepAlpha = EditorGUILayout.Toggle(KeepAlphaStr, m_keepAlpha); EditorGUILayout.Separator(); m_castShadows = EditorGUILayout.Toggle(CastShadowsStr, m_castShadows); //EditorGUILayout.Separator(); //EditorGUILayout.LabelField( _shaderCategoryStr ); //EditorGUI.BeginChangeCheck(); //_shaderCategory = EditorGUILayout.TextField( _shaderCategory, _textfieldStyle ); //if ( EditorGUI.EndChangeCheck() ) //{ // if ( _shaderCategory.Length > 0 ) // _shaderCategory = UIUtils.RemoveInvalidCharacters( _shaderCategory ); //} //EditorGUILayout.Separator(); //_isHidden = EditorGUILayout.ToggleLeft( _isHiddenStr, _isHidden ); //EditorGUILayout.Separator(); //EditorGUIUtility.labelWidth = _materialLen; //bool updateMaterial = false; //EditorGUI.BeginChangeCheck(); //_currentMaterial = ( Material ) EditorGUILayout.ObjectField( _materialStr, _currentMaterial, typeof( Material ), false ); //if ( EditorGUI.EndChangeCheck() ) //{ // updateMaterial = true; //} //EditorGUILayout.Separator(); //EditorGUIUtility.labelWidth = labelWidth; //if ( GUILayout.Button( _pickMaterialStr, _buttonStyle ) ) //{ // if ( Selection.activeGameObject != null ) // { // Renderer renderer = Selection.activeGameObject.GetComponent<Renderer>(); // if ( renderer ) // { // _currentMaterial = renderer.sharedMaterial; // UpdateMaterialEditor(); // } // } //} //if ( _currentMaterial != null ) //{ // if ( /*_materialEditor == null ||*/ updateMaterial ) // { // UpdateMaterialEditor(); // } //} //EditorGUILayout.Separator(); //for ( int i = 0; i < _codeGenerationDataList.Count; i++ ) //{ // _codeGenerationDataList[ i ].IsActive = EditorGUILayout.ToggleLeft( _codeGenerationDataList[ i ].Name, _codeGenerationDataList[ i ].IsActive ); //} //if ( _materialEditor != null ) //{ // if ( _materialLabelStyle == null ) // { // _materialLabelStyle = new GUIStyle( UIUtils.CurrentWindow.CustomStylesInstance.Label ); // _materialLabelStyle.fontStyle = FontStyle.Bold; // _materialLabelStyle.fontSize = 15; // } // EditorGUILayout.LabelField( Constants.LineSeparator ); // EditorGUILayout.Separator(); // EditorGUILayout.LabelField( _materialProperties, _materialLabelStyle, GUILayout.Height( 20 ) ); // EditorGUILayout.Separator(); // _materialEditor.OnInspectorGUI(); //} } EditorGUILayout.EndVertical(); if (m_currentLightModel != m_lastLightModel) { CacheCurrentSettings(); m_lastLightModel = m_currentLightModel; DeleteAllInputConnections(true); AddMasterPorts(); ConnectFromCache(); } }