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.

625 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.IO;
  5. using System.Collections.Generic;
  6. using UnityEditor;
  7. using UnityEngine;
  8. using UnityEditorInternal;
  9. namespace AmplifyShaderEditor
  10. {
  11. public enum AdditionalLineType
  12. {
  13. Include,
  14. Define,
  15. Pragma,
  16. Custom
  17. }
  18. [Serializable]
  19. public class AdditionalDirectiveContainerSaveItem
  20. {
  21. public AdditionalLineType LineType = AdditionalLineType.Include;
  22. public string LineValue = string.Empty;
  23. public bool GUIDToggle = false;
  24. public string GUIDValue = string.Empty;
  25. public AdditionalDirectiveContainerSaveItem( AdditionalLineType lineType, string lineValue, bool guidToggle, string guidValue )
  26. {
  27. LineType = lineType;
  28. LineValue = lineValue;
  29. GUIDToggle = guidToggle;
  30. GUIDValue = guidValue;
  31. }
  32. public AdditionalDirectiveContainerSaveItem( AdditionalDirectiveContainer container )
  33. {
  34. LineType = container.LineType;
  35. LineValue = container.LineValue;
  36. GUIDToggle = container.GUIDToggle;
  37. GUIDValue = container.GUIDValue;
  38. }
  39. }
  40. [Serializable]
  41. public class AdditionalDirectiveContainer : ScriptableObject
  42. {
  43. public AdditionalLineType LineType = AdditionalLineType.Include;
  44. public string LineValue = string.Empty;
  45. public bool GUIDToggle = false;
  46. public string GUIDValue = string.Empty;
  47. public TextAsset LibObject = null;
  48. public void Init( AdditionalDirectiveContainerSaveItem item )
  49. {
  50. LineType = item.LineType;
  51. LineValue = item.LineValue;
  52. GUIDToggle = item.GUIDToggle;
  53. GUIDValue = item.GUIDValue;
  54. if( GUIDToggle )
  55. {
  56. LibObject = AssetDatabase.LoadAssetAtPath<TextAsset>( AssetDatabase.GUIDToAssetPath( GUIDValue ) );
  57. }
  58. }
  59. public void OnDestroy()
  60. {
  61. //Debug.Log( "Destoying directives" );
  62. LibObject = null;
  63. }
  64. public string Value
  65. {
  66. get
  67. {
  68. switch( LineType )
  69. {
  70. case AdditionalLineType.Include:
  71. {
  72. if( GUIDToggle )
  73. {
  74. string shaderPath = AssetDatabase.GUIDToAssetPath( GUIDValue );
  75. if( !string.IsNullOrEmpty( shaderPath ) )
  76. return shaderPath;
  77. }
  78. return LineValue;
  79. }
  80. case AdditionalLineType.Define: return LineValue;
  81. case AdditionalLineType.Pragma: return LineValue;
  82. }
  83. return LineValue;
  84. }
  85. }
  86. public string FormattedValue
  87. {
  88. get
  89. {
  90. switch( LineType )
  91. {
  92. case AdditionalLineType.Include:
  93. {
  94. if( GUIDToggle )
  95. {
  96. string shaderPath = AssetDatabase.GUIDToAssetPath( GUIDValue );
  97. if( !string.IsNullOrEmpty( shaderPath ) )
  98. return string.Format( Constants.IncludeFormat, shaderPath );
  99. }
  100. return string.Format( Constants.IncludeFormat, LineValue );
  101. }
  102. case AdditionalLineType.Define:
  103. return string.Format( Constants.DefineFormat, LineValue );
  104. case AdditionalLineType.Pragma:
  105. return string.Format( Constants.PragmaFormat, LineValue );
  106. }
  107. return LineValue;
  108. }
  109. }
  110. }
  111. public enum ReordableAction
  112. {
  113. None,
  114. Add,
  115. Remove
  116. }
  117. [Serializable]
  118. public sealed class TemplateAdditionalDirectivesHelper : TemplateModuleParent
  119. {
  120. private string NativeFoldoutStr = "Native";
  121. [SerializeField]
  122. private List<AdditionalDirectiveContainer> m_additionalDirectives = new List<AdditionalDirectiveContainer>();
  123. [SerializeField]
  124. private List<AdditionalDirectiveContainer> m_shaderFunctionDirectives = new List<AdditionalDirectiveContainer>();
  125. [SerializeField]
  126. private List<string> m_nativeDirectives = new List<string>();
  127. [SerializeField]
  128. private bool m_nativeDirectivesFoldout = false;
  129. //ONLY USED BY SHADER FUNCTIONS
  130. // Since AdditionalDirectiveContainer must be a ScriptableObject because of serialization shenanigans it will not serialize the info correctly into the shader function when saving it into a file ( it only saves the id )
  131. // For it to properly work, each AdditionalDirectiveContainer should be added to the SF asset, but that would make it to have children ( which are seen on the project inspector )
  132. // Must revisit this later on and come up with a proper solution
  133. [SerializeField]
  134. private List<AdditionalDirectiveContainerSaveItem> m_directivesSaveItems = new List<AdditionalDirectiveContainerSaveItem>();
  135. private ReordableAction m_actionType = ReordableAction.None;
  136. private int m_actionIndex = 0;
  137. private ReorderableList m_reordableList = null;
  138. private GUIStyle m_propertyAdjustment;
  139. private UndoParentNode m_currOwner;
  140. public TemplateAdditionalDirectivesHelper( string moduleName ) : base( moduleName ) { }
  141. //public void AddShaderFunctionItem( AdditionalLineType type, string item )
  142. //{
  143. // UpdateShaderFunctionDictionary();
  144. // string id = type + item;
  145. // if( !m_shaderFunctionDictionary.ContainsKey( id ) )
  146. // {
  147. // AdditionalDirectiveContainer newItem = ScriptableObject.CreateInstance<AdditionalDirectiveContainer>();
  148. // newItem.LineType = type;
  149. // newItem.LineValue = item;
  150. // newItem.hideFlags = HideFlags.HideAndDontSave;
  151. // m_shaderFunctionDirectives.Add( newItem );
  152. // m_shaderFunctionDictionary.Add( id, newItem );
  153. // }
  154. //}
  155. public void AddShaderFunctionItems( List<AdditionalDirectiveContainer> functionList )
  156. {
  157. if( functionList.Count > 0 )
  158. m_shaderFunctionDirectives.AddRange( functionList );
  159. }
  160. public void RemoveShaderFunctionItems( List<AdditionalDirectiveContainer> functionList )
  161. {
  162. for( int i = 0; i < functionList.Count; i++ )
  163. {
  164. m_shaderFunctionDirectives.Remove( functionList[ i ] );
  165. }
  166. }
  167. //public void RemoveShaderFunctionItem( AdditionalLineType type, string item )
  168. //{
  169. // m_shaderFunctionDirectives.RemoveAll( x => x.LineType == type && x.LineValue.Equals( item ) );
  170. //}
  171. public void AddItems( AdditionalLineType type, List<string> items )
  172. {
  173. int count = items.Count;
  174. for( int i = 0; i < count; i++ )
  175. {
  176. AdditionalDirectiveContainer newItem = ScriptableObject.CreateInstance<AdditionalDirectiveContainer>();
  177. newItem.LineType = type;
  178. newItem.LineValue = items[ i ];
  179. newItem.hideFlags = HideFlags.HideAndDontSave;
  180. m_additionalDirectives.Add( newItem );
  181. }
  182. }
  183. public void FillNativeItems( List<string> nativeItems )
  184. {
  185. m_nativeDirectives.Clear();
  186. m_nativeDirectives.AddRange( nativeItems );
  187. }
  188. void DrawNativeItems()
  189. {
  190. EditorGUILayout.Separator();
  191. EditorGUI.indentLevel++;
  192. int count = m_nativeDirectives.Count;
  193. for( int i = 0; i < count; i++ )
  194. {
  195. EditorGUILayout.LabelField( m_nativeDirectives[ i ] );
  196. }
  197. EditorGUI.indentLevel--;
  198. EditorGUILayout.Separator();
  199. }
  200. void DrawButtons()
  201. {
  202. EditorGUILayout.Separator();
  203. // Add keyword
  204. if( GUILayout.Button( string.Empty, UIUtils.PlusStyle, GUILayout.Width( Constants.PlusMinusButtonLayoutWidth ) ) )
  205. {
  206. AdditionalDirectiveContainer newItem = ScriptableObject.CreateInstance<AdditionalDirectiveContainer>();
  207. newItem.hideFlags = HideFlags.HideAndDontSave;
  208. m_additionalDirectives.Add( newItem );
  209. EditorGUI.FocusTextInControl( null );
  210. m_isDirty = true;
  211. }
  212. //Remove keyword
  213. if( GUILayout.Button( string.Empty, UIUtils.MinusStyle, GUILayout.Width( Constants.PlusMinusButtonLayoutWidth ) ) )
  214. {
  215. if( m_additionalDirectives.Count > 0 )
  216. {
  217. AdditionalDirectiveContainer itemToDelete = m_additionalDirectives[ m_additionalDirectives.Count - 1 ];
  218. m_additionalDirectives.RemoveAt( m_additionalDirectives.Count - 1 );
  219. ScriptableObject.DestroyImmediate( itemToDelete );
  220. EditorGUI.FocusTextInControl( null );
  221. }
  222. m_isDirty = true;
  223. }
  224. }
  225. public override void Draw( UndoParentNode currOwner, bool style = true )
  226. {
  227. m_currOwner = currOwner;
  228. if( m_reordableList == null )
  229. {
  230. m_reordableList = new ReorderableList( m_additionalDirectives, typeof( AdditionalDirectiveContainer ), true, false, false, false )
  231. {
  232. headerHeight = 0,
  233. footerHeight = 0,
  234. showDefaultBackground = false,
  235. drawElementCallback = ( Rect rect, int index, bool isActive, bool isFocused ) =>
  236. {
  237. if( m_additionalDirectives[ index ] != null )
  238. {
  239. float labelWidthStyleAdjust = 0;
  240. if( style )
  241. {
  242. rect.xMin -= 10;
  243. labelWidthStyleAdjust = 15;
  244. }
  245. else
  246. {
  247. rect.xMin -= 1;
  248. }
  249. float popUpWidth = style ? 75 : 60f;
  250. float widthAdjust = m_additionalDirectives[ index ].LineType == AdditionalLineType.Include ? -14 : 0;
  251. Rect popupPos = new Rect( rect.x, rect.y, popUpWidth, EditorGUIUtility.singleLineHeight );
  252. Rect GUIDTogglePos = m_additionalDirectives[ index ].LineType == AdditionalLineType.Include ? new Rect( rect.x + rect.width - 3 * Constants.PlusMinusButtonLayoutWidth, rect.y, Constants.PlusMinusButtonLayoutWidth, Constants.PlusMinusButtonLayoutWidth ) : new Rect();
  253. Rect buttonPlusPos = new Rect( rect.x + rect.width - 2 * Constants.PlusMinusButtonLayoutWidth, rect.y - 2, Constants.PlusMinusButtonLayoutWidth, Constants.PlusMinusButtonLayoutWidth );
  254. Rect buttonMinusPos = new Rect( rect.x + rect.width - Constants.PlusMinusButtonLayoutWidth, rect.y - 2, Constants.PlusMinusButtonLayoutWidth, Constants.PlusMinusButtonLayoutWidth );
  255. float labelWidthBuffer = EditorGUIUtility.labelWidth;
  256. Rect labelPos = new Rect( rect.x + popupPos.width - labelWidthStyleAdjust, rect.y, labelWidthStyleAdjust + rect.width - popupPos.width - buttonPlusPos.width - buttonMinusPos.width + widthAdjust, EditorGUIUtility.singleLineHeight );
  257. m_additionalDirectives[ index ].LineType = (AdditionalLineType)m_currOwner.EditorGUIEnumPopup( popupPos, m_additionalDirectives[ index ].LineType );
  258. if( m_additionalDirectives[ index ].LineType == AdditionalLineType.Include )
  259. {
  260. if( m_additionalDirectives[ index ].GUIDToggle )
  261. {
  262. //if( m_additionalDirectives[ index ].LibObject == null && !string.IsNullOrEmpty( m_additionalDirectives[ index ].GUIDValue ) )
  263. //{
  264. // m_additionalDirectives[ index ].LibObject = AssetDatabase.LoadAssetAtPath<TextAsset>( AssetDatabase.GUIDToAssetPath( m_additionalDirectives[ index ].GUIDValue ) );
  265. //}
  266. EditorGUI.BeginChangeCheck();
  267. TextAsset obj = m_currOwner.EditorGUIObjectField( labelPos, m_additionalDirectives[ index ].LibObject, typeof( TextAsset ), false ) as TextAsset;
  268. if( EditorGUI.EndChangeCheck() )
  269. {
  270. string pathName = AssetDatabase.GetAssetPath( obj );
  271. string extension = Path.GetExtension( pathName );
  272. extension = extension.ToLower();
  273. if( extension.Equals( ".cginc" ) || extension.Equals( ".hlsl" ) )
  274. {
  275. m_additionalDirectives[ index ].LibObject = obj;
  276. m_additionalDirectives[ index ].GUIDValue = AssetDatabase.AssetPathToGUID( pathName );
  277. }
  278. }
  279. }
  280. else
  281. {
  282. m_additionalDirectives[ index ].LineValue = m_currOwner.EditorGUITextField( labelPos, string.Empty, m_additionalDirectives[ index ].LineValue );
  283. }
  284. if( GUI.Button( GUIDTogglePos, m_additionalDirectives[ index ].GUIDToggle ? UIUtils.FloatIntIconOFF : UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF ) )
  285. m_additionalDirectives[ index ].GUIDToggle = !m_additionalDirectives[ index ].GUIDToggle;
  286. }
  287. else
  288. {
  289. m_additionalDirectives[ index ].LineValue = m_currOwner.EditorGUITextField( labelPos, string.Empty, m_additionalDirectives[ index ].LineValue );
  290. }
  291. if( GUI.Button( buttonPlusPos, string.Empty, UIUtils.PlusStyle ) )
  292. {
  293. m_actionType = ReordableAction.Add;
  294. m_actionIndex = index;
  295. }
  296. if( GUI.Button( buttonMinusPos, string.Empty, UIUtils.MinusStyle ) )
  297. {
  298. m_actionType = ReordableAction.Remove;
  299. m_actionIndex = index;
  300. }
  301. }
  302. }
  303. };
  304. }
  305. if( m_actionType != ReordableAction.None )
  306. {
  307. switch( m_actionType )
  308. {
  309. case ReordableAction.Add:
  310. AdditionalDirectiveContainer newItem = ScriptableObject.CreateInstance<AdditionalDirectiveContainer>();
  311. newItem.hideFlags = HideFlags.HideAndDontSave;
  312. m_additionalDirectives.Insert( m_actionIndex + 1, newItem );
  313. break;
  314. case ReordableAction.Remove:
  315. AdditionalDirectiveContainer itemToDelete = m_additionalDirectives[ m_actionIndex ];
  316. m_additionalDirectives.RemoveAt( m_actionIndex );
  317. ScriptableObject.DestroyImmediate( itemToDelete );
  318. break;
  319. }
  320. m_isDirty = true;
  321. m_actionType = ReordableAction.None;
  322. EditorGUI.FocusTextInControl( null );
  323. }
  324. bool foldoutValue = currOwner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalDirectives;
  325. if( style )
  326. {
  327. NodeUtils.DrawPropertyGroup( ref foldoutValue, m_moduleName, DrawReordableList, DrawButtons );
  328. }
  329. else
  330. {
  331. NodeUtils.DrawNestedPropertyGroup( ref foldoutValue, m_moduleName, DrawReordableList, DrawButtons );
  332. }
  333. currOwner.ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedAdditionalDirectives = foldoutValue;
  334. }
  335. void DrawReordableList()
  336. {
  337. if( m_reordableList != null )
  338. {
  339. if( m_propertyAdjustment == null )
  340. {
  341. m_propertyAdjustment = new GUIStyle();
  342. m_propertyAdjustment.padding.left = 17;
  343. }
  344. //EditorGUILayout.BeginVertical( m_propertyAdjustment );
  345. EditorGUILayout.Space();
  346. if( m_nativeDirectives.Count > 0 )
  347. {
  348. NodeUtils.DrawNestedPropertyGroup( ref m_nativeDirectivesFoldout, NativeFoldoutStr, DrawNativeItems, 4 );
  349. }
  350. if( m_additionalDirectives.Count == 0 )
  351. {
  352. EditorGUILayout.HelpBox( "Your list is Empty!\nUse the plus button to add one.", MessageType.Info );
  353. }
  354. else
  355. {
  356. m_reordableList.DoLayoutList();
  357. }
  358. EditorGUILayout.Space();
  359. //EditorGUILayout.EndVertical();
  360. }
  361. }
  362. public void AddAllToDataCollector( ref MasterNodeDataCollector dataCollector, TemplateIncludePragmaContainter nativesContainer )
  363. {
  364. AddToDataCollector( ref dataCollector, nativesContainer, false );
  365. AddToDataCollector( ref dataCollector, nativesContainer, true );
  366. }
  367. public void AddAllToDataCollector( ref MasterNodeDataCollector dataCollector )
  368. {
  369. AddToDataCollector( ref dataCollector, false );
  370. AddToDataCollector( ref dataCollector, true );
  371. }
  372. void AddToDataCollector( ref MasterNodeDataCollector dataCollector, TemplateIncludePragmaContainter nativesContainer, bool fromSF )
  373. {
  374. List<AdditionalDirectiveContainer> list = fromSF ? m_shaderFunctionDirectives : m_additionalDirectives;
  375. int count = list.Count;
  376. for( int i = 0; i < count; i++ )
  377. {
  378. switch( list[ i ].LineType )
  379. {
  380. case AdditionalLineType.Include:
  381. {
  382. string value = list[ i ].Value;
  383. if( !string.IsNullOrEmpty( value ) &&
  384. !nativesContainer.HasInclude( value ) )
  385. {
  386. dataCollector.AddToMisc( list[ i ].FormattedValue );
  387. }
  388. }
  389. break;
  390. case AdditionalLineType.Define:
  391. {
  392. if( !string.IsNullOrEmpty( list[ i ].LineValue ) &&
  393. !nativesContainer.HasDefine( list[ i ].LineValue ) )
  394. {
  395. dataCollector.AddToMisc( list[ i ].FormattedValue );
  396. }
  397. }
  398. break;
  399. case AdditionalLineType.Pragma:
  400. {
  401. if( !string.IsNullOrEmpty( list[ i ].LineValue ) &&
  402. !nativesContainer.HasPragma( list[ i ].LineValue ) )
  403. {
  404. dataCollector.AddToMisc( list[ i ].FormattedValue );
  405. }
  406. }
  407. break;
  408. default:
  409. case AdditionalLineType.Custom:
  410. dataCollector.AddToMisc( list[ i ].LineValue );
  411. break;
  412. }
  413. }
  414. }
  415. void AddToDataCollector( ref MasterNodeDataCollector dataCollector, bool fromSF )
  416. {
  417. List<AdditionalDirectiveContainer> list = fromSF ? m_shaderFunctionDirectives : m_additionalDirectives;
  418. int count = list.Count;
  419. for( int i = 0; i < count; i++ )
  420. {
  421. switch( list[ i ].LineType )
  422. {
  423. case AdditionalLineType.Include:
  424. {
  425. string value = list[ i ].FormattedValue;
  426. if( !string.IsNullOrEmpty( value ) )
  427. {
  428. dataCollector.AddToMisc( value );
  429. }
  430. }
  431. break;
  432. case AdditionalLineType.Define:
  433. {
  434. if( !string.IsNullOrEmpty( list[ i ].LineValue ) )
  435. {
  436. dataCollector.AddToMisc( list[ i ].FormattedValue );
  437. }
  438. }
  439. break;
  440. case AdditionalLineType.Pragma:
  441. {
  442. if( !string.IsNullOrEmpty( list[ i ].LineValue ) )
  443. {
  444. dataCollector.AddToMisc( list[ i ].FormattedValue );
  445. }
  446. }
  447. break;
  448. default:
  449. case AdditionalLineType.Custom:
  450. dataCollector.AddToMisc( list[ i ].LineValue );
  451. break;
  452. }
  453. }
  454. }
  455. public override void ReadFromString( ref uint index, ref string[] nodeParams )
  456. {
  457. try
  458. {
  459. int count = Convert.ToInt32( nodeParams[ index++ ] );
  460. for( int i = 0; i < count; i++ )
  461. {
  462. AdditionalLineType lineType = (AdditionalLineType)Enum.Parse( typeof( AdditionalLineType ), nodeParams[ index++ ] );
  463. string lineValue = nodeParams[ index++ ];
  464. AdditionalDirectiveContainer newItem = ScriptableObject.CreateInstance<AdditionalDirectiveContainer>();
  465. newItem.hideFlags = HideFlags.HideAndDontSave;
  466. newItem.LineType = lineType;
  467. newItem.LineValue = lineValue.Replace( Constants.SemiColonSeparator, ';' );
  468. if( UIUtils.CurrentShaderVersion() > 15607 )
  469. {
  470. newItem.GUIDToggle = Convert.ToBoolean( nodeParams[ index++ ] );
  471. newItem.GUIDValue = nodeParams[ index++ ];
  472. if( newItem.GUIDToggle )
  473. {
  474. newItem.LibObject = AssetDatabase.LoadAssetAtPath<TextAsset>( AssetDatabase.GUIDToAssetPath( newItem.GUIDValue ) );
  475. if( newItem.LibObject == null )
  476. {
  477. Debug.LogWarning( "Include file not found with GUID " + newItem.GUIDValue );
  478. }
  479. }
  480. }
  481. m_additionalDirectives.Add( newItem );
  482. }
  483. }
  484. catch( Exception e )
  485. {
  486. Debug.LogException( e );
  487. }
  488. }
  489. public override void WriteToString( ref string nodeInfo )
  490. {
  491. IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalDirectives.Count );
  492. for( int i = 0; i < m_additionalDirectives.Count; i++ )
  493. {
  494. IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalDirectives[ i ].LineType );
  495. IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalDirectives[ i ].LineValue.Replace( ';', Constants.SemiColonSeparator ) );
  496. IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalDirectives[ i ].GUIDToggle );
  497. IOUtils.AddFieldValueToString( ref nodeInfo, m_additionalDirectives[ i ].GUIDValue );
  498. }
  499. }
  500. // read comment on m_directivesSaveItems declaration
  501. public void UpdateSaveItemsFromDirectives()
  502. {
  503. bool foundNull = false;
  504. m_directivesSaveItems.Clear();
  505. for( int i = 0; i < m_additionalDirectives.Count; i++ )
  506. {
  507. if( m_additionalDirectives[ i ] != null )
  508. {
  509. m_directivesSaveItems.Add( new AdditionalDirectiveContainerSaveItem( m_additionalDirectives[ i ] ) );
  510. }
  511. else
  512. {
  513. foundNull = true;
  514. }
  515. }
  516. if( foundNull )
  517. {
  518. m_additionalDirectives.RemoveAll( item => item == null );
  519. }
  520. }
  521. public void CleanNullDirectives()
  522. {
  523. m_additionalDirectives.RemoveAll( item => item == null );
  524. }
  525. // read comment on m_directivesSaveItems declaration
  526. public void UpdateDirectivesFromSaveItems()
  527. {
  528. if( m_directivesSaveItems.Count > 0 )
  529. {
  530. for( int i = 0; i < m_additionalDirectives.Count; i++ )
  531. {
  532. if( m_additionalDirectives[ i ] != null )
  533. ScriptableObject.DestroyImmediate( m_additionalDirectives[ i ] );
  534. }
  535. m_additionalDirectives.Clear();
  536. for( int i = 0; i < m_directivesSaveItems.Count; i++ )
  537. {
  538. AdditionalDirectiveContainer newItem = ScriptableObject.CreateInstance<AdditionalDirectiveContainer>();
  539. newItem.hideFlags = HideFlags.HideAndDontSave;
  540. newItem.Init( m_directivesSaveItems[ i ] );
  541. m_additionalDirectives.Add( newItem );
  542. }
  543. m_directivesSaveItems.Clear();
  544. }
  545. }
  546. public override void Destroy()
  547. {
  548. base.Destroy();
  549. m_nativeDirectives.Clear();
  550. m_nativeDirectives = null;
  551. for( int i = 0; i < m_additionalDirectives.Count; i++ )
  552. {
  553. ScriptableObject.DestroyImmediate( m_additionalDirectives[ i ] );
  554. }
  555. m_additionalDirectives.Clear();
  556. m_additionalDirectives = null;
  557. m_propertyAdjustment = null;
  558. m_reordableList = null;
  559. }
  560. public List<AdditionalDirectiveContainer> DirectivesList { get { return m_additionalDirectives; } }
  561. public bool IsValid { get { return m_validData; } set { m_validData = value; } }
  562. }
  563. }