123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
-
- namespace NRKernal
- {
- using System;
- using UnityEngine;
- #if UNITY_EDITOR
- using UnityEditor;
- using System.IO;
- #endif
-
- [Serializable]
- public struct NRTrackingImageDatabaseEntry
- {
-
- public string Name;
-
- public float Width;
-
- public float Height;
-
- public string Quality;
-
- public string TextureGUID;
-
-
-
-
- public NRTrackingImageDatabaseEntry(string name, float width, float height)
- {
- Name = name;
- TextureGUID = string.Empty;
- Width = width;
- Height = height;
- Quality = string.Empty;
- TextureGUID = string.Empty;
- }
- #if UNITY_EDITOR
-
-
-
-
-
-
- public NRTrackingImageDatabaseEntry(string name, Texture2D texture, float width, float height)
- {
- Name = name;
- TextureGUID = string.Empty;
- Width = width;
- Quality = string.Empty;
- Height = height;
- Texture = texture;
- }
-
-
-
- public NRTrackingImageDatabaseEntry(string name, Texture2D texture)
- {
- Name = name;
- TextureGUID = string.Empty;
- Width = 0;
- Quality = string.Empty;
- Height = 0;
- Texture = texture;
- }
-
-
- public NRTrackingImageDatabaseEntry(Texture2D texture)
- {
- Name = "Unnamed";
- TextureGUID = string.Empty;
- Width = 0;
- Quality = string.Empty;
- Height = 0;
- Texture = texture;
- }
-
-
- public Texture2D Texture
- {
- get
- {
- return AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GUIDToAssetPath(TextureGUID));
- }
- set
- {
- string path = AssetDatabase.GetAssetPath(value);
- TextureGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(value));
- var fileName = Path.GetFileName(path);
- Name = fileName.Replace(Path.GetExtension(fileName), string.Empty);
- }
- }
-
-
- public override string ToString()
- {
- return string.Format("Name:{0} Quality:{1}", Name, Quality);
- }
-
- #endif
- }
- }
|