void OnEnable() { _data = (BiologData)AssetDatabase.LoadAssetAtPath(kBIOLOG_DATA_PATH, typeof(BiologData)); if (_data == null) { _data = ScriptableObject.CreateInstance <BiologData>(); if (!Directory.Exists("Assets/Biolog")) { AssetDatabase.CreateFolder("Assets", "Biolog"); } if (!Directory.Exists("Assets/Biolog/Data")) { AssetDatabase.CreateFolder("Assets/Biolog", "Data"); } AssetDatabase.CreateAsset(_data, kBIOLOG_DATA_PATH); } HashSet <string> allTags = new HashSet <string>(); foreach (var entry in _data.Entries) { foreach (string tag in entry.Tags) { if (!allTags.Contains(tag)) { allTags.Add(tag); } } } minSize = new UnityEngine.Vector2(1000, 600); _model = new BiologEditorModel(this, allTags); _detailView = new BiologEntryDetailView(_model, _data); _listView = new BiologEntryListView(_model, _data); }
public BiologEntryDetailView(BiologEditorModel model, BiologData data) { _data = data; _model = model; _model.SelectedEntryChanged += new Action <BiologEntry>(_model_SelectedEntryChanged); foreach (var entry in data.Entries) { //if (entry.Preview3D) //{ // BiologEntryGalleryItem galleryItem3D = new BiologEntryGalleryItem(); // galleryItem3D.Is3D = true; // galleryItem3D.Scene3D = entry.Preview3D; // entry.GalleryItems.Insert(0, galleryItem3D); // entry.Preview3D = null; //} foreach (var gal in entry.GalleryItems) { //try //{ // string path = AssetDatabase.GetAssetPath(gal.GalleryImage); // Sprite sprite = (Sprite)AssetDatabase.LoadAssetAtPath(path, typeof(Sprite)); // if (!sprite) // { // Debug.Log("Tried to load sprite at " + gal.GalleryImageResourcePath + ", but nothing was returned.", gal.GalleryImage); // } // else // { // gal.GalleryImage = sprite; // } //} //catch (Exception e) //{ // Debug.LogError("Failed to load image at " + gal.GalleryImageResourcePath + " as sprite!"); // continue; //} //try //{ // string path = AssetDatabase.GetAssetPath(gal.GalleryPreview); // Sprite sprite = (Sprite)AssetDatabase.LoadAssetAtPath(path, typeof(Sprite)); // if (!sprite) // { // Debug.Log("Tried to load sprite at " + gal.GalleryPreviewResourcePath + ", but nothing was returned.", gal.GalleryPreview); // } // else // { // gal.GalleryPreview = sprite; // } //} //catch (Exception e) //{ // Debug.LogError("Failed to load image at " + gal.GalleryPreviewResourcePath + " as sprite!"); // continue; //} } } }
public BiologEntryListView(BiologEditorModel model, BiologData biologData) { _biologData = biologData; _model = model; }