private void DrawToolShelf(RouteSet routeset) { var iconAddRoute = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_route") as Texture; var iconExport = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_export") as Texture; Rotorz.Games.Collections.ReorderableListGUI.Title("Tools"); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // Add route button if (FoxKitUiUtils.ToolButton(iconAddRoute, "Add a new route.")) { routeset.AddNewRoute(); } // Export button if (FoxKitUiUtils.ToolButton(iconExport, "Export to .frt file.")) { var exportPath = EditorUtility.SaveFilePanel( "Export frt", string.Empty, routeset.name + ".frt", "frt"); if (string.IsNullOrEmpty(exportPath)) { return; } var hashManager = new StrCode32HashManager(); RouteSetExporter.ExportRouteSet(routeset, hashManager, exportPath); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
public override void DrawItem(Rect position, int index) { var item = this[index]; var editButtonPosition = position; editButtonPosition.width = position.width * 0.8f; FoxKitUiUtils.EntityPtrField(editButtonPosition, item, this.ptrType, () => this.CreateEntity(index)); var wasGuiEnabled = GUI.enabled; if (item == null) { GUI.enabled = false; } var deleteButtonPosition = position; deleteButtonPosition.x += editButtonPosition.width; deleteButtonPosition.width = position.width * 0.2f; if (GUI.Button(deleteButtonPosition, new GUIContent("Delete"), EditorStyles.miniButton)) { this.list[index] = null; } GUI.enabled = wasGuiEnabled; base.DrawItem(position, index); }
public override void OnInspectorGUI() { var asset = (MaterialDatabase)this.target; if (asset.IsReadOnly) { FoxKitUiUtils.ReadOnlyWarningAndButton(asset, duplicate => duplicate.IsReadOnly = false); } if (GUILayout.Button("Export fmtt")) { var exportPath = EditorUtility.SaveFilePanel( "Export fmtt", string.Empty, this.target.name + ".fmtt", "fmtt"); if (string.IsNullOrEmpty(exportPath)) { return; } MaterialDatabaseExporter.ExportMaterialDatabase(asset.materialPresets, exportPath); } this.DrawDefaultInspector(); }
public T DrawEntityPtrItem(Rect position, T itemValue, string key) { var item = this.dictionary[key]; var editButtonPosition = position; editButtonPosition.width = position.width * 0.8f; FoxKitUiUtils.EntityPtrField(editButtonPosition, item, this.ptrType, () => this.CreateEntity(key)); var wasGuiEnabled = GUI.enabled; if (item == null) { GUI.enabled = false; } var deleteButtonPosition = position; deleteButtonPosition.x += editButtonPosition.width; deleteButtonPosition.width = position.width * 0.2f; if (GUI.Button(deleteButtonPosition, new GUIContent("Delete"), EditorStyles.miniButton)) { item = null; this.dictionary[key] = null; } GUI.enabled = wasGuiEnabled; //base.DrawItem(position, index); return(item); }
public override void OnInspectorGUI() { var package = this.target as PackageDefinition; Assert.IsNotNull(package); if (package.IsReadOnly) { FoxKitUiUtils.ReadOnlyWarningAndButton(package, duplicate => duplicate.IsReadOnly = false); } package.Type = (PackageDefinition.PackageType)EditorGUILayout.EnumPopup("Type", package.Type); ReorderableListGUI.Title("Entries"); EditorGUI.BeginChangeCheck(); this.listControl.Draw(this.listAdapter); if (!EditorGUI.EndChangeCheck()) { return; } if (ReorderableListGUI.IndexOfChangedItem == -1) { return; } var dataSet = package.Entries[ReorderableListGUI.IndexOfChangedItem] as EntityFileAsset; if (dataSet != null) { dataSet.PackageGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(this.target)); } }
private static void DrawToolShelf(RouteEvent @event) { var iconAddNode = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_new_node") as Texture; var iconAddEvent = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_new_event") as Texture; var iconParent = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_parent") as Texture; var iconNext = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_next") as Texture; var iconPrev = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_prev") as Texture; Rotorz.Games.Collections.ReorderableListGUI.Title("Tools"); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // Add node button if (FoxKitUiUtils.ToolButton(iconAddNode, "Add a new node.")) { @event.AddNewNode(); } // Add event button if (FoxKitUiUtils.ToolButton(iconAddEvent, "Add a new node event.")) { @event.AddNewRouteNodeEvent(); } // Select parent button if (FoxKitUiUtils.ToolButton(iconParent, "Select parent.")) { UnitySceneUtils.Select(@event.transform.parent.gameObject); } // Select previous node button if (FoxKitUiUtils.ToolButton(iconPrev, "Select previous node.")) { var node = @event.GetComponent <RouteNode>(); if (node == null) { node = @event.transform.parent.GetComponent <RouteNode>(); } node.SelectPreviousNode(); } // Select next node button if (FoxKitUiUtils.ToolButton(iconNext, "Select next node.")) { var node = @event.GetComponent <RouteNode>(); if (node == null) { node = @event.transform.parent.GetComponent <RouteNode>(); } node.SelectNextNode(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); foreach (var command in commands) { if (FoxKitUiUtils.ToolButton(command.Icon, command.Tooltip)) { command.Execute(); } } EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { var asset = (EntityFileAsset)this.target; if (asset.IsReadOnly) { FoxKitUiUtils.ReadOnlyWarningAndButton(asset, thisAsset => thisAsset.IsReadOnly = false); } if (string.IsNullOrEmpty(asset.PackageGuid)) { EditorGUILayout.HelpBox("This DataSet does not belong to a package. Import or create a Package Definition and add this DataSet to it.", MessageType.Warning); } this.DrawDefaultInspector(); }
public override void OnInspectorGUI() { var myTarget = (SkyParameters)this.target; if (myTarget.IsReadOnly) { FoxKitUiUtils.ReadOnlyWarningAndButton(myTarget, asset => asset.IsReadOnly = false); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Export pcsp")) { var exportPath = EditorUtility.SaveFilePanel( "Export pcsp", string.Empty, this.target.name + ".pcsp", "pcsp"); if (string.IsNullOrEmpty(exportPath)) { return; } SkyParametersExporter.ExportSkyParameters(myTarget.precomputedSkyParameters, exportPath); } else if (GUILayout.Button("Export png")) { var exportPath = EditorUtility.SaveFilePanel( "Export png", string.Empty, this.target.name + ".png", "png"); if (string.IsNullOrEmpty(exportPath)) { return; } var pngPixels = (myTarget.precomputedSkyParameters).EncodeToPNG(); File.WriteAllBytes(exportPath, pngPixels); } EditorGUILayout.EndHorizontal(); this.DrawDefaultInspector(); }
private void DrawToolShelf(Route route) { var iconAddNode = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_new_node") as Texture; var iconParent = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_parent") as Texture; Rotorz.Games.Collections.ReorderableListGUI.Title("Tools"); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // Add node button if (FoxKitUiUtils.ToolButton(iconAddNode, "Add a new node to the end of the route.")) { route.AddNewNode(); } // Select parent button if (FoxKitUiUtils.ToolButton(iconParent, "Select parent RouteSet.")) { UnitySceneUtils.Select(route.transform.parent.gameObject); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
private static object DrawField( Entity entity, Tuple <FieldInfo, PropertyInfoAttribute> field, object currentValue) { object newValue = null; switch (field.Item2.Type) { case Core.PropertyInfoType.Int8: newValue = FoxKitUiUtils.SbyteField(field.Item1.Name, (sbyte)currentValue); break; case Core.PropertyInfoType.UInt8: newValue = FoxKitUiUtils.ByteField(field.Item1.Name, (byte)currentValue); break; case Core.PropertyInfoType.Int16: newValue = FoxKitUiUtils.ShortField(field.Item1.Name, (short)currentValue); break; case Core.PropertyInfoType.UInt16: newValue = FoxKitUiUtils.UShortField(field.Item1.Name, (ushort)currentValue); break; case Core.PropertyInfoType.Int32: if (field.Item2.Enum != null) { newValue = EditorGUILayout.EnumPopup(field.Item1.Name, (Enum)currentValue); } else { newValue = EditorGUILayout.IntField(field.Item1.Name, (int)currentValue); } break; case Core.PropertyInfoType.UInt32: newValue = FoxKitUiUtils.UIntField(field.Item1.Name, (uint)currentValue); break; case Core.PropertyInfoType.Int64: newValue = EditorGUILayout.LongField(field.Item1.Name, (long)currentValue); break; case Core.PropertyInfoType.UInt64: newValue = FoxKitUiUtils.ULongField(field.Item1.Name, (ulong)currentValue); break; case Core.PropertyInfoType.Float: newValue = EditorGUILayout.FloatField(field.Item1.Name, (float)currentValue); break; case Core.PropertyInfoType.Double: newValue = EditorGUILayout.DoubleField(field.Item1.Name, (double)currentValue); break; case Core.PropertyInfoType.Bool: newValue = EditorGUILayout.Toggle(field.Item1.Name, (bool)currentValue); break; case Core.PropertyInfoType.String: newValue = EditorGUILayout.TextField(field.Item1.Name, field.Item1.GetValue(entity) as string); break; case Core.PropertyInfoType.Path: newValue = EditorGUILayout.ObjectField( field.Item1.Name, field.Item1.GetValue(entity) as UnityEngine.Object, typeof(UnityEngine.Object), false); break; case Core.PropertyInfoType.EntityPtr: newValue = FoxKitUiUtils.EntityPtrField( field.Item1.Name, currentValue, field.Item2.PtrType, () => AddEntityWindow.Create(field.Item2.PtrType, true, type => field.Item1.SetValue(entity, CreateEntity(type, entity))), dataElement => DestroyEntity(dataElement, entity)); break; case Core.PropertyInfoType.Vector3: newValue = EditorGUILayout.Vector3Field( field.Item1.Name, (UnityEngine.Vector3)field.Item1.GetValue(entity)); break; case Core.PropertyInfoType.Vector4: newValue = EditorGUILayout.Vector4Field( field.Item1.Name, (UnityEngine.Vector4)field.Item1.GetValue(entity)); break; case Core.PropertyInfoType.Quat: newValue = FoxKitUiUtils.QuaternionField(field.Item1.Name, (UnityEngine.Quaternion)currentValue); break; case Core.PropertyInfoType.Matrix3: Assert.IsTrue(false, "There shouldn't be any Matrix3 properties. Report this."); break; case Core.PropertyInfoType.Matrix4: EditorGUILayout.HelpBox("Matrix4 properties are not currently supported.", MessageType.Error); break; case Core.PropertyInfoType.Color: newValue = EditorGUILayout.ColorField(field.Item1.Name, (Color)field.Item1.GetValue(entity)); break; case Core.PropertyInfoType.FilePtr: newValue = EditorGUILayout.ObjectField( field.Item1.Name, field.Item1.GetValue(entity) as UnityEngine.Object, typeof(UnityEngine.Object), false); break; case Core.PropertyInfoType.EntityHandle: newValue = FoxKitUiUtils.EntityHandleField(field.Item1.Name, currentValue, typeof(Entity)); break; case Core.PropertyInfoType.EntityLink: var link = field.Item1.GetValue(entity) as EntityLink; Action <Data> onEntitySelected = selected => link.Entity = selected; Action <DataIdentifier, string> onDataIdentifierEntitySelected = (identifier, key) => link.SetDataIdentifier(identifier, key); newValue = FoxKitUiUtils.EntityLinkField(field.Item1.Name, link, onEntitySelected, onDataIdentifierEntitySelected); break; default: throw new ArgumentOutOfRangeException(); } return(newValue); }
private static T DrawListItem <T>( Rect position, T itemValue, Core.PropertyInfoType type, Type @enum, Type ptrType, Action <Type> createEntityCallback = null) { object newValue = null; switch (type) { case Core.PropertyInfoType.Int8: newValue = FoxKitUiUtils.SbyteField(position, (sbyte)(object)itemValue); break; case Core.PropertyInfoType.UInt8: newValue = FoxKitUiUtils.ByteField(position, (byte)(object)itemValue); break; case Core.PropertyInfoType.Int16: newValue = FoxKitUiUtils.ShortField(position, (short)(object)itemValue); break; case Core.PropertyInfoType.UInt16: newValue = FoxKitUiUtils.UShortField(position, (ushort)(object)itemValue); break; case Core.PropertyInfoType.Int32: if (@enum != null) { // I'm sorry var enumValue = (Enum)Enum.ToObject(@enum, itemValue); newValue = EditorGUI.EnumPopup(position, enumValue); } else { newValue = EditorGUI.IntField(position, (int)(object)itemValue); } break; case Core.PropertyInfoType.UInt32: //newValue = FoxKitUiUtils.UIntField(position, (uint)(object)itemValue); if (@enum != null) { newValue = EditorGUI.EnumPopup(position, (Enum)(object)itemValue); } else { newValue = FoxKitUiUtils.UIntField(position, (uint)(object)itemValue); } break; case Core.PropertyInfoType.Int64: newValue = EditorGUI.LongField(position, (long)(object)itemValue); break; case Core.PropertyInfoType.UInt64: newValue = FoxKitUiUtils.ULongField(position, (ulong)(object)itemValue); break; case Core.PropertyInfoType.Float: newValue = EditorGUI.FloatField(position, (float)(object)itemValue); break; case Core.PropertyInfoType.Double: newValue = EditorGUI.DoubleField(position, (double)(object)itemValue); break; case Core.PropertyInfoType.Bool: newValue = EditorGUI.Toggle(position, (bool)(object)itemValue); break; case Core.PropertyInfoType.String: newValue = EditorGUI.TextField(position, (string)(object)itemValue); break; case Core.PropertyInfoType.Path: newValue = EditorGUI.ObjectField( position, itemValue as UnityEngine.Object, typeof(UnityEngine.Object), false); break; case Core.PropertyInfoType.EntityPtr: newValue = FoxKitUiUtils.EntityPtrField( position, itemValue, ptrType, () => AddEntityWindow.Create(ptrType, true, createEntityCallback)); break; case Core.PropertyInfoType.Vector3: newValue = EditorGUI.Vector3Field(position, string.Empty, (UnityEngine.Vector3)(object) itemValue); break; case Core.PropertyInfoType.Vector4: newValue = EditorGUI.Vector4Field(position, string.Empty, (UnityEngine.Vector4)(object) itemValue); break; case Core.PropertyInfoType.Quat: newValue = FoxKitUiUtils.QuaternionField(position, (UnityEngine.Quaternion)(object) itemValue); break; case Core.PropertyInfoType.Matrix3: Assert.IsTrue(false, "There shouldn't be any Matrix3 properties. Report this."); break; case Core.PropertyInfoType.Matrix4: // TODO //Debug.LogWarning("Matrix4 properties not currently supported."); EditorGUI.HelpBox(position, "Matrix4 properties are not currently supported.", MessageType.Error); newValue = itemValue; break; case Core.PropertyInfoType.Color: newValue = EditorGUI.ColorField(position, (Color)(object)itemValue); break; case Core.PropertyInfoType.FilePtr: newValue = EditorGUI.ObjectField( position, itemValue as UnityEngine.Object, typeof(UnityEngine.Object), false); break; case Core.PropertyInfoType.EntityHandle: newValue = FoxKitUiUtils.EntityHandleField(position, itemValue, typeof(Entity)); break; case Core.PropertyInfoType.EntityLink: var link = itemValue as EntityLink; Action <Data> entitySelected = selected => link.Entity = selected; Action <DataIdentifier, string> dataIdentifierEntitySelected = (identifier, key) => link.SetDataIdentifier(identifier, key); newValue = FoxKitUiUtils.EntityLinkField( position, (EntityLink)(object)itemValue, entitySelected, dataIdentifierEntitySelected); break; default: throw new ArgumentOutOfRangeException(); } return((T)newValue); }