void DeleteButtonOnAttachment(Rect targetRect, InfoLogEntry entry, int index) { if (GUI.Button(new Rect(targetRect.xMax - 20, targetRect.yMin + 4, 16, 16), "X")) { DeleteAttachment(entry, index); } }
void DrawCommentInfo(InfoLogEntry entry) { GUILayout.BeginVertical(); entry.entryType = (InfoLogEntry.EntryType)EditorGUILayout.EnumPopup("Info Type", entry.entryType); entry.briefDescription = EditorGUILayout.TextField("Brief", entry.briefDescription); GUILayout.Label("Detail"); entry.contentDescription = EditorGUILayout.TextArea(entry.contentDescription, GUILayout.MinHeight(60)); DrawAttachedImages(entry); GUILayout.EndVertical(); }
public static InfoLogEntry Create() { InfoLogEntry created = ScriptableObject.CreateInstance <InfoLogEntry>(); created.index = -1; created.entryType = EntryType.Article; created.briefDescription = "Some Desc"; created.attachedImages = new List <Sprite>(); created.ID = created.GetInstanceID(); created.imageCaptions = new List <string>(); return(created); }
void OnEntryItemInserted(object sender, ItemInsertedEventArgs args) { InfoLogEntry newEntry = InfoLogEntry.Create(); AddSubAsset(newEntry, infoGroupCache); infoGroupCache.entries[args.ItemIndex] = newEntry; DrawSideBar_Entry = DrawSideBar_Entries_Normal; DrawEditor = DrawEditor_Normal; SaveDatabase(); }
void OnAddNewEntryButtonClicked() { InfoLogEntry newEntry = InfoLogEntry.Create(); AddSubAsset(newEntry, infoGroupCache); infoGroupCache.entries.Add(newEntry); CacheEntryTags(); DrawSideBar_Entry = DrawSideBar_Entries_Normal; DrawEditor = DrawEditor_Normal; SaveDatabase(); }
void DrawAttachedImages(InfoLogEntry entry) { GUILayout.Label("Attached Images"); GUILayout.BeginHorizontal(GUILayout.Height(160)); GUILayout.Space(8); for (int i = 0; i < entry.attachedImages.Count; i++) { Rect temp; GUILayout.BeginVertical(GUILayout.Width(160)); GUILayout.Space(4); GUILayout.Box(GUIContent.none, GUILayout.Width(160), GUILayout.Height(160)); temp = GUILayoutUtility.GetLastRect(); GUI.DrawTextureWithTexCoords(temp, BoxBG, new Rect(0, 0, 12, 12)); CustomEditorUtility.DrawRectOutline(temp); GUI.DrawTexture(CustomEditorUtility.RectScaler(temp, 0.96f), entry.attachedImages[i].texture, ScaleMode.ScaleToFit); entry.attachedImages[i] = EditorGUILayout.ObjectField(entry.attachedImages[i], typeof(Sprite), false) as Sprite; entry.imageCaptions[i] = EditorGUILayout.TextField(entry.imageCaptions[i]); GUILayout.EndVertical(); DeleteButtonOnAttachment(temp, entry, i); } GUILayout.BeginVertical(GUILayout.Height(160)); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Layout_ImagePickerButton("+", ref imagePickerBuffer, GUIUtility.GetControlID(FocusType.Passive), GUILayout.Width(32), GUILayout.Height(32)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.Space(8); GUILayout.EndHorizontal(); CustomEditorUtility.DrawRectOutline(GUILayoutUtility.GetLastRect()); if (imagePickerBuffer != null) { entry.attachedImages.Add(imagePickerBuffer); entry.imageCaptions.Add(""); imagePickerBuffer = null; } }
void DeleteAttachment(InfoLogEntry entry, int index) { entry.attachedImages.RemoveAt(index); entry.imageCaptions.RemoveAt(index); }
void DrawGalleryInfo(InfoLogEntry entry) { entry.entryType = (InfoLogEntry.EntryType)EditorGUILayout.EnumPopup("Info Type", entry.entryType); entry.briefDescription = EditorGUILayout.TextField("Brief", entry.briefDescription); DrawAttachedImages(entry); }
InfoLogEntry DrawListEntry(Rect position, InfoLogEntry entry) { EditorGUI.SelectableLabel(position, entry.briefDescription); return(entry); }