ImagePage.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. */
  8. using Meta.Voice.Hub.Attributes;
  9. using Meta.Voice.Hub.Interfaces;
  10. using Meta.Voice.Hub.UIComponents;
  11. using UnityEditor;
  12. using UnityEngine;
  13. namespace Meta.Voice.Hub
  14. {
  15. [MetaHubPageScriptableObject]
  16. public class ImagePage : ScriptableObject
  17. {
  18. [SerializeField] public Texture2D image;
  19. }
  20. [CustomEditor(typeof(ImagePage))]
  21. public class ImageDisplayScriptableObjectEditor : Editor
  22. {
  23. private ImagePage _imageDisplay;
  24. private ImageView _imageView;
  25. private void OnEnable()
  26. {
  27. _imageDisplay = (ImagePage)target;
  28. _imageView = new ImageView(this);
  29. }
  30. public override void OnInspectorGUI()
  31. {
  32. if (_imageDisplay.image)
  33. {
  34. _imageView.Draw(_imageDisplay.image);
  35. }
  36. else
  37. {
  38. // Draw the default properties
  39. base.OnInspectorGUI();
  40. }
  41. }
  42. }
  43. }