Assignment for RMIT Mixed Reality in 2020
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.

48 lines
1.7 KiB

  1. // Amplify Shader Editor - Visual Shader Editing Tool
  2. // Copyright (c) Amplify Creations, Lda <info@amplify.pt>
  3. using UnityEngine;
  4. using UnityEditor;
  5. using UnityEditor.ProjectWindowCallback;
  6. using System.IO;
  7. namespace AmplifyShaderEditor
  8. {
  9. public class DoCreateStandardShader : EndNameEditAction
  10. {
  11. public override void Action( int instanceId, string pathName, string resourceFile )
  12. {
  13. string uniquePath = AssetDatabase.GenerateUniqueAssetPath( pathName );
  14. string shaderName = Path.GetFileName( uniquePath );
  15. if( IOUtils.AllOpenedWindows.Count > 0 )
  16. {
  17. EditorWindow openedWindow = AmplifyShaderEditorWindow.GetWindow<AmplifyShaderEditorWindow>();
  18. AmplifyShaderEditorWindow currentWindow = AmplifyShaderEditorWindow.CreateTab();
  19. WindowHelper.AddTab( openedWindow, currentWindow );
  20. UIUtils.CurrentWindow = currentWindow;
  21. }
  22. else
  23. {
  24. AmplifyShaderEditorWindow currentWindow = AmplifyShaderEditorWindow.OpenWindow( shaderName, UIUtils.ShaderIcon );
  25. UIUtils.CurrentWindow = currentWindow;
  26. }
  27. Shader shader = UIUtils.CreateNewEmpty( uniquePath, shaderName );
  28. ProjectWindowUtil.ShowCreatedAsset( shader );
  29. }
  30. }
  31. public class DoCreateTemplateShader : EndNameEditAction
  32. {
  33. public override void Action( int instanceId, string pathName, string resourceFile )
  34. {
  35. string uniquePath = AssetDatabase.GenerateUniqueAssetPath( pathName );
  36. string shaderName = Path.GetFileName( uniquePath );
  37. if( !string.IsNullOrEmpty( UIUtils.NewTemplateGUID ) )
  38. {
  39. Shader shader = AmplifyShaderEditorWindow.CreateNewTemplateShader( UIUtils.NewTemplateGUID, uniquePath, shaderName );
  40. ProjectWindowUtil.ShowCreatedAsset( shader );
  41. }
  42. }
  43. }
  44. }