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.

37 lines
805 B

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. namespace AmplifyShaderEditor
  4. {
  5. // Catch when scene is saved (Ctr+S) and also save ase shader
  6. public class SceneSaveCallback : UnityEditor.AssetModificationProcessor
  7. {
  8. private const string UnityStr = ".unity";
  9. static string[] OnWillSaveAssets( string[] paths )
  10. {
  11. bool canSave = false;
  12. if ( paths.Length == 0 )
  13. {
  14. canSave = true;
  15. }
  16. else
  17. {
  18. for ( int i = 0; i < paths.Length; i++ )
  19. {
  20. // Only save shader when saving scenes
  21. if ( paths[ i ].Contains( UnityStr ) )
  22. {
  23. canSave = true;
  24. break;
  25. }
  26. }
  27. }
  28. if ( canSave && UIUtils.CurrentWindow )
  29. UIUtils.CurrentWindow.SetCtrlSCallback( false );
  30. return paths;
  31. }
  32. }
  33. }