OptionsGUI.cs 773 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. using UnityARInterface;
  3. public class OptionsGUI : MonoBehaviour
  4. {
  5. [SerializeField]
  6. private GUISkin m_GuiSkin;
  7. private void DoButton<T>(float y, string name) where T : MonoBehaviour
  8. {
  9. var buttonWidth = 400;
  10. var buttonHeight = Screen.height / 8;
  11. var component = GetComponent<T>();
  12. var rect = new Rect(0, y * buttonHeight, buttonWidth, buttonHeight);
  13. var text = string.Format("{0} {1}", (component.enabled ? "Hide" : "Show"), name);
  14. if (GUI.Button(rect, text, m_GuiSkin.button))
  15. component.enabled = !component.enabled;
  16. }
  17. private void OnGUI()
  18. {
  19. DoButton<ARPlaneVisualizer>(0f, "Planes");
  20. DoButton<ARPointCloudVisualizer>(1f, "Pointcloud");
  21. }
  22. }