You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

650 lines
20 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using System;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEditor;
  7. namespace AmplifyShaderEditor
  8. {
  9. public enum ShaderPropertyScope
  10. {
  11. Shader,
  12. SubShader,
  13. Pass
  14. }
  15. [Serializable]
  16. [NodeAttributes( "Template Parameter", "Constants And Properties", "Select and use one of the pre-existing properties given by the template" )]
  17. public sealed class TemplateShaderPropertyNode : TemplateNodeParent
  18. {
  19. private const string CurrentScopeStr = "Scope";
  20. private const string WarningStr = "Preview doesn't work with global variables";
  21. private const string PropertyLabelStr = "Parameter";
  22. private const string TypeLabelStr = "Type: ";
  23. private const string PropertyNameStr = "Property Name: ";
  24. private int IntPropertyId;
  25. private int FloatPropertyId;
  26. private int VectorPropertyId;
  27. private int Sampler2DPropertyId;
  28. private int Sampler3DPropertyId;
  29. private int SamplerCubePropertyId;
  30. [SerializeField]
  31. private int m_currentPropertyIdx = -1;
  32. [SerializeField]
  33. private string m_propertyName = string.Empty;
  34. [SerializeField]
  35. private int m_propertyNameId = 0;
  36. [SerializeField]
  37. private string m_typeName = string.Empty;
  38. [SerializeField]
  39. private string m_propertyNameLabel = string.Empty;
  40. private bool m_fetchPropertyId = false;
  41. private bool m_fetchScopeFromProperty = false;
  42. private List<TemplateShaderPropertyData> m_shaderProperties = null;
  43. private string[] m_propertyLabels = null;
  44. private UpperLeftWidgetHelper m_upperLeftWidgetHelper = new UpperLeftWidgetHelper();
  45. //Multi-Pass only properties
  46. [SerializeField]
  47. private ShaderPropertyScope m_currentScope = ShaderPropertyScope.Shader;
  48. protected override void CommonInit( int uniqueId )
  49. {
  50. base.CommonInit( uniqueId );
  51. m_previewShaderGUID = "4feb2016be0ece148b8bf234508f6aa4";
  52. }
  53. void FetchScope()
  54. {
  55. int shaderScopeCount = m_templateMPData.AvailableShaderProperties.Count;
  56. for( int i = 0; i < shaderScopeCount; i++ )
  57. {
  58. if( m_templateMPData.AvailableShaderProperties[ i ].PropertyName.Equals( m_propertyName ) )
  59. {
  60. m_currentScope = ShaderPropertyScope.Shader;
  61. }
  62. }
  63. int subShaderScopeCount = m_templateMPData.SubShaders[ SubShaderIdx ].AvailableShaderGlobals.Count;
  64. for( int i = 0; i < subShaderScopeCount; i++ )
  65. {
  66. if( m_templateMPData.SubShaders[ SubShaderIdx ].AvailableShaderGlobals[ i ].PropertyName.Equals( m_propertyName ) )
  67. {
  68. m_currentScope = ShaderPropertyScope.SubShader;
  69. }
  70. }
  71. int passScopeCount = m_templateMPData.SubShaders[ SubShaderIdx ].Passes[ PassIdx ].AvailableShaderGlobals.Count;
  72. for( int i = 0; i < passScopeCount; i++ )
  73. {
  74. if( m_templateMPData.SubShaders[ SubShaderIdx ].Passes[ PassIdx ].AvailableShaderGlobals[ i ].PropertyName.Equals( m_propertyName ) )
  75. {
  76. m_currentScope = ShaderPropertyScope.Pass;
  77. }
  78. }
  79. }
  80. void FetchShaderProperties()
  81. {
  82. if( m_templateMPData == null )
  83. m_templateMPData = ( m_containerGraph.CurrentMasterNode as TemplateMultiPassMasterNode ).CurrentTemplate;
  84. if( m_templateMPData != null )
  85. {
  86. switch( m_currentScope )
  87. {
  88. case ShaderPropertyScope.Shader:
  89. m_shaderProperties = m_templateMPData.AvailableShaderProperties;
  90. break;
  91. case ShaderPropertyScope.SubShader:
  92. m_shaderProperties = m_templateMPData.SubShaders[ SubShaderIdx ].AvailableShaderGlobals;
  93. break;
  94. case ShaderPropertyScope.Pass:
  95. m_shaderProperties = m_templateMPData.SubShaders[ SubShaderIdx ].Passes[ PassIdx ].AvailableShaderGlobals;
  96. break;
  97. }
  98. }
  99. }
  100. public override void OnEnable()
  101. {
  102. base.OnEnable();
  103. IntPropertyId = Shader.PropertyToID( "_IntData" );
  104. FloatPropertyId = Shader.PropertyToID( "_FloatData" );
  105. VectorPropertyId = Shader.PropertyToID( "_VectorData" );
  106. Sampler2DPropertyId = Shader.PropertyToID( "_Sampler2DData" );
  107. Sampler3DPropertyId = Shader.PropertyToID( "_Sampler3DData" );
  108. SamplerCubePropertyId = Shader.PropertyToID( "_SamplerCubeData" );
  109. }
  110. public override void DrawProperties()
  111. {
  112. base.DrawProperties();
  113. if( m_multiPassMode )
  114. {
  115. DrawMultipassProperties();
  116. }
  117. if( m_currentPropertyIdx > -1 )
  118. {
  119. bool hasProperties = ( m_shaderProperties != null && m_shaderProperties.Count > 0 );
  120. if( hasProperties )
  121. {
  122. EditorGUI.BeginChangeCheck();
  123. m_currentPropertyIdx = EditorGUILayoutPopup( PropertyLabelStr, m_currentPropertyIdx, m_propertyLabels );
  124. if( EditorGUI.EndChangeCheck() )
  125. {
  126. UpdateFromId();
  127. }
  128. EditorGUILayout.LabelField( m_typeName );
  129. if( m_shaderProperties[ m_currentPropertyIdx ].PropertyType != PropertyType.Global )
  130. {
  131. EditorGUILayout.LabelField( m_propertyNameLabel );
  132. }
  133. }
  134. }
  135. }
  136. void DrawMultipassProperties()
  137. {
  138. EditorGUI.BeginChangeCheck();
  139. m_currentScope = (ShaderPropertyScope)EditorGUILayoutEnumPopup( CurrentScopeStr, m_currentScope );
  140. if( EditorGUI.EndChangeCheck() )
  141. {
  142. FetchShaderProperties();
  143. FetchPropertyId();
  144. }
  145. bool showSubShader = false;
  146. bool showPass = false;
  147. switch( m_currentScope )
  148. {
  149. case ShaderPropertyScope.SubShader:
  150. {
  151. showSubShader = true;
  152. }
  153. break;
  154. case ShaderPropertyScope.Pass:
  155. {
  156. showSubShader = true;
  157. showPass = true;
  158. }
  159. break;
  160. }
  161. if( showSubShader )
  162. {
  163. DrawSubShaderUI();
  164. }
  165. if( showPass )
  166. {
  167. DrawPassUI();
  168. }
  169. }
  170. protected override void OnSubShaderChange()
  171. {
  172. FetchShaderProperties();
  173. FetchPropertyId();
  174. }
  175. protected override void OnPassChange()
  176. {
  177. FetchShaderProperties();
  178. FetchPropertyId();
  179. }
  180. override protected void CheckWarningState()
  181. {
  182. if( m_containerGraph.CurrentCanvasMode != NodeAvailability.TemplateShader )
  183. {
  184. ShowTab( NodeMessageType.Error, ErrorMessageStr );
  185. }
  186. else
  187. {
  188. if( m_shaderProperties != null &&
  189. m_shaderProperties.Count > 0 &&
  190. m_shaderProperties.Count > m_currentPropertyIdx &&
  191. m_shaderProperties[ m_currentPropertyIdx ].PropertyType == PropertyType.Global &&
  192. m_showPreview )
  193. {
  194. ShowTab( NodeMessageType.Info, WarningStr );
  195. }
  196. else
  197. {
  198. m_showErrorMessage = false;
  199. }
  200. }
  201. }
  202. public override void SetPreviewInputs()
  203. {
  204. if( m_containerGraph.CurrentCanvasMode != NodeAvailability.TemplateShader )
  205. return;
  206. if( m_shaderProperties == null || m_currentPropertyIdx >= m_shaderProperties.Count )
  207. return;
  208. if( m_shaderProperties[ m_currentPropertyIdx ].PropertyType == PropertyType.Global )
  209. {
  210. m_additionalContent.text = string.Empty;
  211. PreviewMaterial.SetInt( IntPropertyId, 0 );
  212. return;
  213. }
  214. Material currMat = m_containerGraph.CurrentMaterial;
  215. if( currMat != null && currMat.HasProperty( m_propertyNameId ) )
  216. {
  217. switch( m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType )
  218. {
  219. case WirePortDataType.INT:
  220. {
  221. int value = currMat.GetInt( m_propertyNameId );
  222. SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, GenerateTitle( value ) ) );
  223. PreviewMaterial.SetInt( IntPropertyId, value );
  224. }
  225. break;
  226. case WirePortDataType.FLOAT:
  227. {
  228. float value = currMat.GetFloat( m_propertyNameId );
  229. SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, GenerateTitle( value ) ) );
  230. PreviewMaterial.SetFloat( FloatPropertyId, value );
  231. }
  232. break;
  233. case WirePortDataType.FLOAT4:
  234. {
  235. Vector4 value = currMat.GetVector( m_propertyNameId );
  236. SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, GenerateTitle( value.x, value.y, value.z, value.w ) ) );
  237. PreviewMaterial.SetVector( VectorPropertyId, value );
  238. }
  239. break;
  240. case WirePortDataType.COLOR:
  241. {
  242. Color value = currMat.GetColor( m_propertyNameId );
  243. SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, GenerateTitle( value.r, value.g, value.b, value.a ) ) );
  244. PreviewMaterial.SetColor( VectorPropertyId, value );
  245. }
  246. break;
  247. case WirePortDataType.SAMPLER2D:
  248. {
  249. Texture value = currMat.GetTexture( m_propertyNameId );
  250. if( value )
  251. SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, value.name ) );
  252. else
  253. SetAdditonalTitleText( string.Empty );
  254. PreviewMaterial.SetTexture( Sampler2DPropertyId, value );
  255. }
  256. break;
  257. case WirePortDataType.SAMPLER3D:
  258. {
  259. Texture value = currMat.GetTexture( m_propertyNameId );
  260. if( value )
  261. SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, value.name ) );
  262. else
  263. SetAdditonalTitleText( string.Empty );
  264. PreviewMaterial.SetTexture( Sampler3DPropertyId, value );
  265. }
  266. break;
  267. case WirePortDataType.SAMPLERCUBE:
  268. {
  269. Texture value = currMat.GetTexture( m_propertyNameId );
  270. if( value )
  271. SetAdditonalTitleText( string.Format( Constants.SubTitleValueFormatStr, value.name ) );
  272. else
  273. SetAdditonalTitleText( string.Empty );
  274. PreviewMaterial.SetTexture( SamplerCubePropertyId, value );
  275. }
  276. break;
  277. }
  278. }
  279. else
  280. {
  281. SetAdditonalTitleText( string.Empty );
  282. }
  283. }
  284. public override void Draw( DrawInfo drawInfo )
  285. {
  286. if( m_containerGraph.CurrentCanvasMode != NodeAvailability.TemplateShader )
  287. {
  288. if( !m_showErrorMessage || m_errorMessageTypeIsError == NodeMessageType.Info )
  289. {
  290. ShowTab( NodeMessageType.Error, ErrorMessageStr );
  291. }
  292. }
  293. else if( m_showErrorMessage )
  294. {
  295. if( m_errorMessageTypeIsError == NodeMessageType.Error )
  296. HideTab();
  297. }
  298. base.Draw( drawInfo );
  299. if( m_containerGraph.CurrentCanvasMode != NodeAvailability.TemplateShader )
  300. return;
  301. if( m_shaderProperties == null )
  302. {
  303. MasterNode masterNode = m_containerGraph.CurrentMasterNode;
  304. if( masterNode.CurrentMasterNodeCategory == AvailableShaderTypes.Template )
  305. {
  306. if( SetTemplate( masterNode ) )
  307. {
  308. m_fetchPropertyId = true;
  309. }
  310. }
  311. }
  312. if( m_fetchScopeFromProperty )
  313. {
  314. m_fetchScopeFromProperty = false;
  315. FetchScope();
  316. FetchShaderProperties();
  317. }
  318. if( m_fetchPropertyId )
  319. {
  320. m_fetchPropertyId = false;
  321. FetchPropertyId();
  322. }
  323. if( m_currentPropertyIdx > -1 )
  324. {
  325. EditorGUI.BeginChangeCheck();
  326. m_currentPropertyIdx = m_upperLeftWidgetHelper.DrawWidget( this, m_currentPropertyIdx, m_propertyLabels );
  327. if( EditorGUI.EndChangeCheck() )
  328. {
  329. UpdateFromId();
  330. }
  331. }
  332. }
  333. void FetchPropertyId()
  334. {
  335. if( m_shaderProperties != null )
  336. {
  337. m_currentPropertyIdx = 0;
  338. m_propertyLabels = new string[ m_shaderProperties.Count ];
  339. for( int i = 0; i < m_shaderProperties.Count; i++ )
  340. {
  341. if( m_shaderProperties[ i ].PropertyName.Equals( m_propertyName ) )
  342. {
  343. m_currentPropertyIdx = i;
  344. }
  345. m_propertyLabels[ i ] = m_shaderProperties[ i ].PropertyInspectorName;
  346. }
  347. UpdateFromId();
  348. }
  349. else
  350. {
  351. m_currentPropertyIdx = -1;
  352. }
  353. }
  354. void UpdateFromId()
  355. {
  356. if( m_shaderProperties != null )
  357. {
  358. if( m_shaderProperties.Count == 0 )
  359. {
  360. for( int i = 0; i < 4; i++ )
  361. m_containerGraph.DeleteConnection( false, UniqueId, i, false, true );
  362. m_headerColor = UIUtils.GetColorFromCategory( "Default" );
  363. m_content.text = "None";
  364. m_additionalContent.text = string.Empty;
  365. m_previewMaterialPassId = 1;
  366. PreviewMaterial.SetFloat( FloatPropertyId, 0 );
  367. m_showPreview = false;
  368. m_drawPreviewExpander = false;
  369. m_outputPorts[ 0 ].ChangeProperties( "None", WirePortDataType.FLOAT, false );
  370. ConfigurePorts();
  371. return;
  372. }
  373. m_drawPreviewExpander = true;
  374. bool areCompatible = TemplateHelperFunctions.CheckIfCompatibles( m_outputPorts[ 0 ].DataType, m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType );
  375. switch( m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType )
  376. {
  377. case WirePortDataType.SAMPLER1D:
  378. case WirePortDataType.SAMPLER2D:
  379. case WirePortDataType.SAMPLER3D:
  380. case WirePortDataType.SAMPLERCUBE:
  381. m_outputPorts[ 0 ].ChangeProperties( "Tex", m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType, false );
  382. m_headerColor = UIUtils.GetColorFromCategory( "Textures" );
  383. break;
  384. case WirePortDataType.INT:
  385. case WirePortDataType.FLOAT:
  386. m_outputPorts[ 0 ].ChangeProperties( Constants.EmptyPortValue, m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType, false );
  387. m_headerColor = UIUtils.GetColorFromCategory( "Constants And Properties" );
  388. break;
  389. case WirePortDataType.FLOAT4:
  390. m_outputPorts[ 0 ].ChangeProperties( "XYZW", m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType, false );
  391. m_headerColor = UIUtils.GetColorFromCategory( "Constants And Properties" );
  392. break;
  393. case WirePortDataType.COLOR:
  394. m_outputPorts[ 0 ].ChangeProperties( "RGBA", m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType, false );
  395. m_headerColor = UIUtils.GetColorFromCategory( "Constants And Properties" );
  396. break;
  397. default:
  398. case WirePortDataType.OBJECT:
  399. case WirePortDataType.FLOAT3x3:
  400. case WirePortDataType.FLOAT4x4:
  401. m_outputPorts[ 0 ].ChangeProperties( "Out", m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType, false );
  402. m_headerColor = UIUtils.GetColorFromCategory( "Constants And Properties" );
  403. break;
  404. }
  405. if( !areCompatible )
  406. {
  407. for( int i = 0; i < 4; i++ )
  408. m_containerGraph.DeleteConnection( false, UniqueId, i, false, true );
  409. }
  410. ConfigurePorts();
  411. m_propertyName = m_shaderProperties[ m_currentPropertyIdx ].PropertyName;
  412. m_content.text = m_shaderProperties[ m_currentPropertyIdx ].PropertyInspectorName;
  413. m_propertyNameId = Shader.PropertyToID( m_propertyName );
  414. m_typeName = TypeLabelStr + m_shaderProperties[ m_currentPropertyIdx ].PropertyType.ToString();
  415. if( m_shaderProperties[ m_currentPropertyIdx ].PropertyType != PropertyType.Global )
  416. {
  417. m_propertyNameLabel = PropertyNameStr + m_shaderProperties[ m_currentPropertyIdx ].PropertyName;
  418. }
  419. m_sizeIsDirty = true;
  420. Material currMat = m_containerGraph.CurrentMaterial;
  421. if( currMat != null )
  422. {
  423. if( m_shaderProperties[ m_currentPropertyIdx ].PropertyType == PropertyType.Global )
  424. {
  425. m_previewMaterialPassId = 0;
  426. if( !m_showErrorMessage && m_showPreview )
  427. {
  428. ShowTab( NodeMessageType.Info, WarningStr );
  429. }
  430. }
  431. else
  432. {
  433. if( m_showErrorMessage && m_errorMessageTypeIsError != NodeMessageType.Error )
  434. {
  435. HideTab();
  436. }
  437. switch( m_shaderProperties[ m_currentPropertyIdx ].PropertyDataType )
  438. {
  439. case WirePortDataType.INT: m_previewMaterialPassId = 0; break;
  440. case WirePortDataType.FLOAT: m_previewMaterialPassId = 1; break;
  441. case WirePortDataType.FLOAT4:
  442. case WirePortDataType.COLOR: m_previewMaterialPassId = 2; break;
  443. case WirePortDataType.SAMPLER2D: m_previewMaterialPassId = 3; break;
  444. case WirePortDataType.SAMPLER3D: m_previewMaterialPassId = 4; break;
  445. case WirePortDataType.SAMPLERCUBE: m_previewMaterialPassId = 5; break;
  446. default: PreviewMaterial.SetPass( 0 ); break;
  447. }
  448. }
  449. }
  450. CheckWarningState();
  451. }
  452. }
  453. string GenerateTitle( params float[] values )
  454. {
  455. //string finalResult = "( ";
  456. string finalResult = string.Empty;
  457. if( values.Length == 1 )
  458. {
  459. finalResult += values[ 0 ].ToString( Mathf.Abs( values[ 0 ] ) > 1000 ? Constants.PropertyBigFloatFormatLabel : Constants.PropertyFloatFormatLabel );
  460. }
  461. else
  462. {
  463. for( int i = 0; i < values.Length; i++ )
  464. {
  465. finalResult += values[ i ].ToString( Mathf.Abs( values[ i ] ) > 1000 ? Constants.PropertyBigVectorFormatLabel : Constants.PropertyVectorFormatLabel );
  466. if( i < ( values.Length - 1 ) )
  467. finalResult += ",";
  468. }
  469. }
  470. //finalResult += " )";
  471. return finalResult;
  472. }
  473. public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
  474. {
  475. if( dataCollector.MasterNodeCategory != AvailableShaderTypes.Template )
  476. {
  477. UIUtils.ShowMessage( "Template Parameter node is only intended for templates use only" );
  478. return m_outputPorts[ outputId ].ErrorValue;
  479. }
  480. if( m_shaderProperties == null || m_shaderProperties.Count ==0 )
  481. {
  482. UIUtils.ShowMessage( "Attempting to fetch inexistant parameter on " + m_nodeAttribs.Name +" node");
  483. return m_outputPorts[ outputId ].ErrorValue;
  484. }
  485. if( m_multiPassMode )
  486. {
  487. switch( m_currentScope )
  488. {
  489. case ShaderPropertyScope.SubShader:
  490. {
  491. if( dataCollector.TemplateDataCollectorInstance.MultipassSubshaderIdx != SubShaderIdx )
  492. {
  493. UIUtils.ShowMessage( string.Format( "{0} is only intended for subshader {1}", m_propertyLabels[ m_currentPropertyIdx ], SubShaderIdx ) );
  494. return m_outputPorts[ outputId ].ErrorValue;
  495. }
  496. }
  497. break;
  498. case ShaderPropertyScope.Pass:
  499. {
  500. if( dataCollector.TemplateDataCollectorInstance.MultipassSubshaderIdx != SubShaderIdx ||
  501. dataCollector.TemplateDataCollectorInstance.MultipassPassIdx != PassIdx
  502. )
  503. {
  504. UIUtils.ShowMessage( string.Format( "{0} is only intended for subshader {1} and pass {2}", m_propertyLabels[ m_currentPropertyIdx ], SubShaderIdx, PassIdx ) );
  505. return m_outputPorts[ outputId ].ErrorValue;
  506. }
  507. }
  508. break;
  509. }
  510. }
  511. return GetOutputVectorItem( 0, outputId, m_propertyName );
  512. }
  513. public override void ReadFromString( ref string[] nodeParams )
  514. {
  515. base.ReadFromString( ref nodeParams );
  516. m_propertyName = GetCurrentParam( ref nodeParams );
  517. m_propertyNameId = Shader.PropertyToID( m_propertyName );
  518. if( UIUtils.CurrentShaderVersion() > TemplatesManager.MPShaderVersion )
  519. {
  520. m_currentScope = (ShaderPropertyScope)Enum.Parse( typeof( ShaderPropertyScope ), GetCurrentParam( ref nodeParams ) );
  521. }
  522. else
  523. {
  524. m_fetchScopeFromProperty = true;
  525. }
  526. m_fetchPropertyId = true;
  527. }
  528. public override void WriteToString( ref string nodeInfo, ref string connectionsInfo )
  529. {
  530. base.WriteToString( ref nodeInfo, ref connectionsInfo );
  531. IOUtils.AddFieldValueToString( ref nodeInfo, m_propertyName );
  532. IOUtils.AddFieldValueToString( ref nodeInfo, m_currentScope );
  533. }
  534. public override void OnMasterNodeReplaced( MasterNode newMasterNode )
  535. {
  536. base.OnMasterNodeReplaced( newMasterNode );
  537. if( newMasterNode.CurrentMasterNodeCategory == AvailableShaderTypes.Template )
  538. {
  539. SetTemplate( newMasterNode );
  540. if( m_fetchScopeFromProperty )
  541. {
  542. m_fetchScopeFromProperty = false;
  543. FetchScope();
  544. }
  545. FetchShaderProperties();
  546. FetchPropertyId();
  547. //m_containerGraph.DeleteConnection( false, UniqueId, 0, false, true );
  548. }
  549. }
  550. bool SetTemplate( MasterNode newMasterNode )
  551. {
  552. if( m_containerGraph.MultiPassMasterNodes.NodesList.Count > 0 )
  553. {
  554. m_multiPassMode = true;
  555. TemplateMultiPassMasterNode templateMasterNode = ( newMasterNode as TemplateMultiPassMasterNode );
  556. if( templateMasterNode != null )
  557. {
  558. m_templateMPData = templateMasterNode.CurrentTemplate;
  559. UpdateSubShaderAmount();
  560. FetchShaderProperties();
  561. return true;
  562. }
  563. }
  564. else
  565. {
  566. m_multiPassMode = false;
  567. TemplateMasterNode templateMasterNode = ( newMasterNode as TemplateMasterNode );
  568. if( templateMasterNode != null )
  569. {
  570. m_shaderProperties = templateMasterNode.CurrentTemplate.AvailableShaderProperties;
  571. return true;
  572. }
  573. }
  574. return false;
  575. }
  576. public override void RefreshExternalReferences()
  577. {
  578. base.RefreshExternalReferences();
  579. CheckWarningState();
  580. }
  581. public override void Destroy()
  582. {
  583. base.Destroy();
  584. m_propertyLabels = null;
  585. m_shaderProperties = null;
  586. m_upperLeftWidgetHelper = null;
  587. }
  588. }
  589. }