public override void OnGUIModule(Rect r, NGRemoteHierarchyWindow hierarchy) { using (LabelWidthRestorer.Get(110F)) { r.height = Constants.SingleLineHeight; EditorGUI.BeginChangeCheck(); this.useJPG = EditorGUI.Toggle(r, "Use JPG", this.useJPG); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetBool(ScreenshotModuleEditor.UseJPGKeyPref, this.useJPG, true); if (hierarchy.IsClientConnected() == true) { hierarchy.Client.AddPacket(new ClientModuleSetUseJPGPacket(this.useJPG)); } } r.y += r.height + 2F; EditorGUI.BeginChangeCheck(); this.useCompression = EditorGUI.Toggle(r, "Use Compression", this.useCompression); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetBool(ScreenshotModuleEditor.UseCompressionKeyPref, this.useCompression, true); if (hierarchy.IsClientConnected() == true) { hierarchy.Client.AddPacket(new ClientModuleSetUseCompressionPacket(this.useCompression)); } } r.y += r.height + 2F; EditorGUI.BeginChangeCheck(); r.width = 210F; this.scaleMode = (ScaleMode)NGEditorGUILayout.EnumPopup(r, "Scale Mode", this.scaleMode); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetInt(ScreenshotModuleEditor.ScaleModeKeyPref, (int)this.scaleMode, true); } } }
public void Draw(Rect r, float viewYMin, float viewYMax) { float x = r.x; float xMax = r.xMax; r.height = Constants.SingleLineHeight; r.width = r.height; if (r.yMax > viewYMin) { EditorGUI.showMixedValue = this.HasMixedRefs(); EditorGUI.BeginChangeCheck(); EditorGUI.ToggleLeft(r, string.Empty, this.referenced); if (EditorGUI.EndChangeCheck() == true) { if (this.referenced == true) { this.Unreference(); } else { this.Reference(); } } r.x += r.width + r.width; EditorGUI.showMixedValue = false; GUI.DrawTexture(r, Folder.folderIcon); r.x += r.width; r.xMax = xMax; r.xMin -= r.height + r.height; EditorGUI.BeginChangeCheck(); EditorGUI.Foldout(r, this.Open, " " + this.name, true); if (EditorGUI.EndChangeCheck() == true) { this.Open = !this.open; if (Event.current.alt == true) { Queue <Folder> queue = new Queue <Folder>(128); queue.Enqueue(this); while (queue.Count > 0) { Folder current = queue.Dequeue(); for (int i = 0; i < current.folders.Count; i++) { queue.Enqueue(current.folders[i]); } current.open = this.open; current.height = -1F; EditorPrefs.SetBool(EmbedAssetsBrowserWindow.Folder.EnableFolderPrefKey + current.GetHierarchyPath(), this.open); } } } } else { r.xMax = xMax; } if (this.open == true) { r.x = x + 16F; r.y += r.height; for (int i = 0; i < this.folders.Count; i++) { if (this.folders[i].folders.Count == 0 && this.folders[i].files.Count == 0) { continue; } r.height = this.folders[i].GetHeight(); this.folders[i].Draw(r, viewYMin, viewYMax); r.y += r.height; } if (r.yMin > viewYMax) { return; } r.height = Constants.SingleLineHeight; for (int i = 0; i < this.files.Count; i++) { if (r.yMax > viewYMin) { EditorGUI.BeginChangeCheck(); Texture2D icon = Utility.GetIcon(AssetDatabase.LoadMainAssetAtPath(this.files[i].path)); if (icon == null) { icon = InternalEditorUtility.GetIconForFile(this.files[i].path); } r.width = r.height; r.x += r.width; GUI.DrawTexture(r, icon); r.x -= r.width; EditorGUI.BeginDisabledGroup(!this.files[i].isValid); { r.xMax = xMax; this.files[i].referenced = EditorGUI.ToggleLeft(r, " " + this.files[i].name, this.files[i].referenced); if (EditorGUI.EndChangeCheck() == true) { EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <Object>(this.files[i].path)); if (this.files[i].referenced == false || EmbedAssetsBrowserWindow.CheckEmbeddableFile(this.files[i]) == true) { this.Update(); } else { if (NGEditorPrefs.GetBool(Folder.AlertNullAssetPrefKey) == false && EditorUtility.DisplayDialog(Constants.PackageTitle, "Asset at \"" + this.files[i].path + "\" contains null assets.\nFix them and reference again.", "OK", "Don't show again") == false) { NGEditorPrefs.SetBool(Folder.AlertNullAssetPrefKey, true); } this.files[i].referenced = false; } } } EditorGUI.EndDisabledGroup(); } r.y += r.height; if (r.yMin > viewYMax) { return; } } } }
protected virtual void OnDisable() { NGEditorPrefs.SetBool(SubmissionWindow.AutoPublishKeyPref, this.autoPublish); NGEditorPrefs.SetString(SubmissionWindow.AutoPublishKeyPref + this.assetName, this.comments); }
public override void Save(string path) { NGEditorPrefs.SetBool(path, (bool)this.value); }
public override object OnGUI(Rect r, object instance) { r.height = Constants.SingleLineHeight; --EditorGUI.indentLevel; r.x += 3F; if (instance == null) { EditorGUI.BeginChangeCheck(); EditorGUI.Foldout(r, false, this.label + " (Null)", false); if (EditorGUI.EndChangeCheck() == true) { GUI.changed = false; } } else { EditorGUI.BeginChangeCheck(); this.isExpanded = EditorGUI.Foldout(r, this.isExpanded, this.label, true); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetBool(path, this.isExpanded); GUI.changed = false; } } r.x -= 3F; ++EditorGUI.indentLevel; if (this.isExpanded == true) { if (instance != null) { this.InitMembers(); try { ++EditorGUI.indentLevel; for (int i = 0; i < this.members.Length; i++) { r.y += r.height + 2F; if (this.members[i].exception != null) { r.height = 16F; using (ColorContentRestorer.Get(Color.red)) EditorGUI.LabelField(r, this.members[i].fieldModifier.Name, "Property raised an exception"); continue; } try { r.height = this.members[i].typeDrawer.GetHeight(this.members[i].fieldModifier.GetValue(instance)); if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition) == true && Event.current.button == 1) { NGStaticInspectorWindow.forceMemberEditable = this.members[i]; EditorWindow window = EditorWindow.mouseOverWindow; if (window != null) { window.Repaint(); } Utility.RegisterIntervalCallback(() => { NGStaticInspectorWindow.forceMemberEditable = null; }, NGStaticInspectorWindow.ForceMemberEditableTickDuration, 1); } bool enabled = GUI.enabled; GUI.enabled = !(!this.members[i].isEditable && NGStaticInspectorWindow.forceMemberEditable != this.members[i]); EditorGUI.BeginChangeCheck(); object value = this.members[i].typeDrawer.OnGUI(r, this.members[i].fieldModifier.GetValue(instance)); if (EditorGUI.EndChangeCheck() == true) { if (this.members[i].isEditable == true) { this.members[i].fieldModifier.SetValue(instance, value); } else { GUI.changed = false; } } GUI.enabled = enabled; } catch (Exception ex) { this.members[i].exception = ex; } } } finally { --EditorGUI.indentLevel; } } } return(instance); }
public override object OnGUI(Rect r, object instance) { r.height = Constants.SingleLineHeight; --EditorGUI.indentLevel; r.x += 3F; if (instance == null) { EditorGUI.BeginChangeCheck(); EditorGUI.Foldout(r, false, this.label + " (Null)", false); if (EditorGUI.EndChangeCheck() == true) { GUI.changed = false; } } else { EditorGUI.BeginChangeCheck(); this.isExpanded = EditorGUI.Foldout(r, this.isExpanded, this.label, true); if (EditorGUI.EndChangeCheck() == true) { NGEditorPrefs.SetBool(path, this.isExpanded); GUI.changed = false; } } r.x -= 3F; ++EditorGUI.indentLevel; if (this.isExpanded == true) { r.y += r.height + 2F; ++EditorGUI.indentLevel; ICollectionModifier collection = NGTools.Utility.GetCollectionModifier(instance); if (collection != null) { try { Type subType = collection.SubType; EditorGUI.BeginChangeCheck(); int size = EditorGUI.DelayedIntField(r, "Size", collection.Size); if (EditorGUI.EndChangeCheck() == true) { size = Mathf.Max(0, size); if (collection.Size != size) { --EditorGUI.indentLevel; if (instance is Array) { Array newArray = Array.CreateInstance(subType, size); Array.Copy(instance as Array, newArray, Mathf.Min(collection.Size, size)); if (collection.Size > 0) { object lastValue = collection.Get(collection.Size - 1); for (int i = collection.Size; i < size; i++) { newArray.SetValue(lastValue, i); } } instance = newArray; } else if (instance is IList) { IList list = instance as IList; if (list.Count < size) { object lastValue = list.Count > 0 ? list[list.Count - 1] : (subType.IsValueType == true ? Activator.CreateInstance(subType) : null); while (list.Count < size) { list.Add(lastValue); } } else { while (list.Count > size) { list.RemoveAt(list.Count - 1); } } instance = list; } else { throw new NotImplementedException("Collection of type \"" + instance.GetType() + "\" is not supported."); } } return(instance); } while (this.drawers.Count < collection.Size) { this.drawers.Add(TypeDrawerManager.GetDrawer(this.path + '.' + this.drawers.Count.ToCachedString(), "Element " + this.drawers.Count.ToCachedString(), subType)); } for (int i = 0; i < collection.Size; i++) { r.y += r.height + 2F; object element = collection.Get(i); r.height = this.drawers[i].GetHeight(element); EditorGUI.BeginChangeCheck(); object value = this.drawers[i].OnGUI(r, element); if (EditorGUI.EndChangeCheck() == true) { collection.Set(i, value); } } } finally { NGTools.Utility.ReturnCollectionModifier(collection); } } --EditorGUI.indentLevel; } return(instance); }