public override void OnInspectorGUI() { GUILayout.BeginVertical(); this.DrawDefaultInspector(); GUILayout.Space(16f); bool externalOperation = false; if (GUILayout.Button("Generate Marker")) { externalOperation = true; TrackableData.EditorCreateIssue(); } GUILayout.EndVertical(); if (externalOperation) { // This has to be here otherwise we get strange GUI stack exceptions EditorGUIUtility.ExitGUI(); } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { db = (TrackableData)target; Texture2D result = null; if (db != null && db.image != null) { result = db.image; } if (result != null) { GUI.DrawTexture(r, result, ScaleMode.ScaleToFit); } }
/// <summary> /// Creates a new trackable asset using KARMarker data from a selected file. /// </summary> public static void EditorCreateIssue() { string path = UnityEditor.EditorUtility.OpenFilePanel("Kudan AR", "", "KARMarker"); if (!string.IsNullOrEmpty(path)) { TrackableData obj = ScriptableObject.CreateInstance <TrackableData>(); UnityEditor.AssetDatabase.CreateAsset(obj, "Assets/NewKudanTrackable.asset"); UnityEditor.AssetDatabase.SaveAssets(); obj.id = System.IO.Path.GetFileNameWithoutExtension(path); obj.data = System.IO.File.ReadAllBytes(path); UnityEditor.EditorUtility.SetDirty(obj); UnityEditor.EditorUtility.FocusProjectWindow(); UnityEditor.Selection.activeObject = obj; } }
void Awake() { db = (TrackableData)target; }