Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEditor;
- using UnityEngine.UIElements;
- using UnityEditor.UIElements;
- [CustomEditor(typeof(imguiOver))]
- public class imguiTest : Editor
- {
- Texture2D texture, none;
- int index;
- public override void OnInspectorGUI()
- {
- texture = AssetDatabase.LoadAssetAtPath<Texture2D>($"Assets/Models/Resources/icon{index}.png");
- none = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Models/Resources/none.png");
- index = EditorGUILayout.IntField(index);
- if (texture != null)
- {
- GUILayout.Box(texture);
- GUILayout.Label($"IMGUI Testing, texture {texture.name} is load");
- }
- else
- {
- GUILayout.Box(none);
- GUILayout.Label("Nothing is loaded");
- }
- }
- }
- [CustomEditor(typeof(monoOverride))]
- public class img_testing : Editor
- {
- Texture2D texture, none;
- int index;
- public override VisualElement CreateInspectorGUI()
- {
- texture = AssetDatabase.LoadAssetAtPath<Texture2D>($"Assets/Models/Resources/icon{index}.png");
- none = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Models/Resources/none.png");
- var root = new VisualElement();
- var lbl = new Label();
- var img = new Image ();
- img.scaleMode = ScaleMode.ScaleToFit;
- if (texture != null)
- {
- lbl.text = $"texture {texture.name} is load";
- img.image = texture;
- }
- else
- {
- lbl.text = "Nothing is loaded";
- img.image = none;
- }
- root.Add(img);
- root.Add(lbl);
- var intField = new IntegerField();
- index = intField.value;
- root.Add(intField);
- return root;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement