Ei kuvausta
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.

EditorPathUtils.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System;
  15. using System.IO;
  16. using UnityEditor;
  17. using UnityEngine;
  18. /*
  19. * EditorPathUtils class finds and processes the AssetPath for
  20. * EditorPathUtils.cs within unity asset database.
  21. */
  22. public class EditorPathUtils : ScriptableObject
  23. {
  24. /*
  25. * Returns the asset path of EditorPathUtils.cs
  26. */
  27. private String GetFilePath()
  28. {
  29. return AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(this));
  30. }
  31. /*
  32. * Returns the asset directory path of EditorPathUtils.cs
  33. */
  34. public String GetDirectoryAssetPath()
  35. {
  36. return Path.GetDirectoryName(GetFilePath());
  37. }
  38. /*
  39. * Returns the parent asset directory path of EditorPathUtils.cs
  40. */
  41. public String GetParentDirectoryAssetPath()
  42. {
  43. return Path.GetDirectoryName(GetDirectoryAssetPath());
  44. }
  45. /*
  46. * Returns true if GMA import is done via unity package manager,
  47. * false otherwise.
  48. */
  49. public bool IsPackageRootPath()
  50. {
  51. return GetFilePath().StartsWith("Packages");
  52. }
  53. }