public void DictionaryChanged() { if (id > NativePlugin.get_dictionary_words()) { File.Delete(GetImagePath(id)); File.Delete(GetImagePath(id) + ".meta"); id = 0; } RefreshTexture(); }
public void SetID(int newid) { if (markers.Contains(newid)) { return; } if (newid >= 0 && newid <= NativePlugin.get_dictionary_words() && newid != id) { markers.Add(newid); markers.Remove(id); File.Delete(GetImagePath(id)); File.Delete(GetImagePath(id) + ".meta"); id = newid; RefreshTexture(); } }
public bool RefreshTexture() { InitTexture(); if (id < 0 || id >= NativePlugin.get_dictionary_words()) { return(false); } filepath = GetImagePath(id); NativePlugin.get_marker_texture(id, size, filepath); if (!File.Exists(filepath)) { return(false); } FileStream fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read); fileStream.Seek(0, SeekOrigin.Begin); byte[] bytes = new byte[fileStream.Length]; fileStream.Read(bytes, 0, (int)fileStream.Length); fileStream.Close(); fileStream.Dispose(); if ((object)texture == null) { return(false); } if (!texture.LoadImage(bytes)) { return(false); } return(true); }
public override void OnInspectorGUI() { ARMarker marker = (ARMarker)target; if (marker == null) { return; } string idlabel = String.Format("id [0,{0})", NativePlugin.get_dictionary_words()); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(idlabel); marker.SetID(EditorGUILayout.IntField(marker.id)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("length(m)"); marker.length = EditorGUILayout.FloatField(marker.length); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("use background color"); marker.SetUseBackgroundColor(EditorGUILayout.Toggle(marker.useBackgroundColor)); EditorGUILayout.EndHorizontal(); if (marker.useBackgroundColor) { marker.SetBackgroundColor(EditorGUILayout.ColorField("background color", marker.backgroundColor)); } else { EditorGUILayout.ObjectField("texture", marker.texture, typeof(Texture2D), true); } }