Selection.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using BansheeEngine;
  4. namespace BansheeEditor
  5. {
  6. public sealed class Selection
  7. {
  8. public static Action<SceneObject[], string[]> OnSelectionChanged;
  9. public static Action<SceneObject> OnSceneObjectPing;
  10. public static Action<string> OnResourcePing;
  11. public static SceneObject[] sceneObjects
  12. {
  13. get
  14. {
  15. SceneObject[] selection;
  16. Internal_GetSceneObjectSelection(out selection);
  17. return selection;
  18. }
  19. set
  20. {
  21. Internal_SetSceneObjectSelection(value);
  22. }
  23. }
  24. public static string[] resourceUUIDs
  25. {
  26. get
  27. {
  28. string[] selection;
  29. Internal_GetResourceUUIDSelection(out selection);
  30. return selection;
  31. }
  32. set
  33. {
  34. Internal_SetResourceUUIDSelection(value);
  35. }
  36. }
  37. public static string[] resourcePaths
  38. {
  39. get
  40. {
  41. string[] selection;
  42. Internal_GetResourcePathSelection(out selection);
  43. return selection;
  44. }
  45. set
  46. {
  47. Internal_SetResourcePathSelection(value);
  48. }
  49. }
  50. public static void Ping(Resource resource)
  51. {
  52. string path = ProjectLibrary.GetPath(resource);
  53. Internal_PingResource(path);
  54. }
  55. public static void Ping(SceneObject so)
  56. {
  57. Internal_PingSceneObject(so);
  58. }
  59. private static void Internal_TriggerSelectionChanged(SceneObject[] objects, string[] paths)
  60. {
  61. if (OnSelectionChanged != null)
  62. OnSelectionChanged(objects, paths);
  63. }
  64. private static void Internal_TriggerSceneObjectPing(SceneObject so)
  65. {
  66. if (OnSceneObjectPing != null)
  67. OnSceneObjectPing(so);
  68. }
  69. private static void Internal_TriggerResourcePing(string path)
  70. {
  71. if (OnResourcePing != null)
  72. OnResourcePing(path);
  73. }
  74. [MethodImpl(MethodImplOptions.InternalCall)]
  75. internal static extern void Internal_GetSceneObjectSelection(out SceneObject[] selection);
  76. [MethodImpl(MethodImplOptions.InternalCall)]
  77. internal static extern void Internal_SetSceneObjectSelection(SceneObject[] selection);
  78. [MethodImpl(MethodImplOptions.InternalCall)]
  79. internal static extern void Internal_GetResourceUUIDSelection(out string[] selection);
  80. [MethodImpl(MethodImplOptions.InternalCall)]
  81. internal static extern void Internal_SetResourceUUIDSelection(string[] selection);
  82. [MethodImpl(MethodImplOptions.InternalCall)]
  83. internal static extern void Internal_GetResourcePathSelection(out string[] selection);
  84. [MethodImpl(MethodImplOptions.InternalCall)]
  85. internal static extern void Internal_SetResourcePathSelection(string[] selection);
  86. [MethodImpl(MethodImplOptions.InternalCall)]
  87. internal static extern void Internal_PingResource(string resourcePath);
  88. [MethodImpl(MethodImplOptions.InternalCall)]
  89. internal static extern void Internal_PingSceneObject(SceneObject so);
  90. }
  91. }