MaterialHeaderHelpLuxURPURLDecorator.cs 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace LuxURPEssentials
  5. {
  6. public class MaterialHeaderHelpLuxURP_URLDecorator : MaterialPropertyDrawer {
  7. private string url;
  8. private GUIContent buttonGUIContent;
  9. public MaterialHeaderHelpLuxURP_URLDecorator(string url) {
  10. this.url = "https://docs.google.com/document/d/1ck3hmPzKUdewHfwsvmPYwSPCP8azwtpzN7aOLJHvMqE/edit#heading=h." + url;
  11. var helpIcon = EditorGUIUtility.FindTexture("_Help");
  12. buttonGUIContent = new GUIContent(helpIcon, "Open Online Documentation");
  13. }
  14. public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor editor) {
  15. var headerPos = new Rect(position.x, position.y, position.width - 20, 20);
  16. var btnPos = new Rect(position.x + headerPos.width, position.y, 20, 20);
  17. GUI.Label(headerPos, new GUIContent("Help"), EditorStyles.boldLabel);
  18. if (GUI.Button(btnPos, buttonGUIContent, EditorStyles.boldLabel)) {
  19. Help.BrowseURL(this.url);
  20. }
  21. }
  22. public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor) {
  23. return 20;
  24. }
  25. }
  26. }