public override void Setup(Roster target, SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute) { _roster = target; _owner = property.serializedObject.targetObject; _controls = new List <CreatureReferenceControl>(); _listControl.Setup(_roster) .MakeDrawable(DrawCreature) .MakeRemovable(_removeButton) .MakeCollapsable(property.serializedObject.targetObject.GetType() + "." + property.propertyPath + ".IsOpen") .MakeReorderable() .MakeHeaderButton(_addSpeciesButton, _addSpeciesMenu, Color.white) .MakeHeaderButton(_addCreatureButton, _addCreatureMenu, Color.white) .MakeCustomHeight(GetCreatureHeight) .MakeEmptyLabel(_emptyLabel); var species = AssetHelper.GetAssetList <Species>(false, false); for (var i = 0; i < species.Assets.Count; i++) { if (species.Assets[i] != null) { _addSpeciesMenu.AddItem(species.Names[i], false, AddSpecies, species.Assets[i]); _addCreatureMenu.AddItem(species.Names[i], false, AddCreature, species.Assets[i]); } } }
public static Instruction Draw(Rect position, GUIContent label, Instruction instruction) { var popup = AssetHelper.GetAssetList(typeof(Instruction), true, true); var index = popup.GetIndex(instruction); var buttonRect = instruction == null ? position : RectHelper.TakeTrailingIcon(ref position); var selectedIndex = EditorGUI.Popup(position, label, index, popup.Names); if (selectedIndex != index) { instruction = popup.GetAsset(selectedIndex) as Instruction; if (instruction == null) { var type = popup.GetType(selectedIndex); if (type != null) { instruction = AssetHelper.CreateAsset(type.Name, type) as Instruction; } } } if (instruction != null) { if (GUI.Button(buttonRect, _editButton.Content, GUIStyle.none)) { Selection.activeObject = instruction; } } return(instruction); }
private void ShowGraphPicker(Vector2 position) { var graphs = AssetHelper.GetAssetList <Graph>(); _graphProvider.Setup("Select Graph", graphs.Paths, graphs.Assets.Cast <Graph>().ToList(), graph => AssetPreview.GetMiniThumbnail(graph), selectedGraph => SetGraph(selectedGraph)); SearchWindow.Open(new SearchWindowContext(position), _graphProvider); }
private void BuildZoneList() { var zoneList = AssetHelper.GetAssetList <Zone>(false, false); if (zoneList != _zoneList) { _zoneNames = new GUIContent[zoneList.Names.Length + 3]; _zoneList = zoneList; Array.Copy(zoneList.Names, 0, _zoneNames, 3, zoneList.Names.Length); _zoneNames[0] = _activeZoneOptionContent; _zoneNames[1] = _savedZoneOptionContent; _zoneNames[2] = new GUIContent(string.Empty); } }
public override void Setup(MoveList target, SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute) { _list = target; _owner = property.serializedObject.targetObject; _listControl.Setup(_list) .MakeEditable(_editButton) .MakeRemovable(_removeButton) .MakeDrawable(DrawMove) .MakeCollapsable(property.serializedObject.targetObject.GetType() + "." + property.propertyPath + ".IsOpen") .MakeReorderable() .MakeHeaderButton(_addButton, _addMenu, Color.white) .MakeEmptyLabel(_emptyLabel); var abilities = AssetHelper.GetAssetList <Ability>(false, false); for (var i = 0; i < abilities.Assets.Count; i++) { if (abilities.Assets[i] != null) { _addMenu.AddItem(abilities.Names[i], false, AddMove, abilities.Assets[i]); } } }
public override void Setup(Inventory target, SerializedProperty property, FieldInfo fieldInfo, PropertyAttribute attribute) { _inventory = target; _owner = property.serializedObject.targetObject; _listControl.Setup(_inventory.Items) .MakeEditable(_editButton) .MakeRemovable(_removeButton) .MakeDrawable(DrawItem) .MakeCollapsable(property.serializedObject.targetObject.GetType().Name + "." + property.propertyPath + ".IsOpen") .MakeReorderable() .MakeHeaderButton(_addButton, _addMenu, Color.white) .MakeEmptyLabel(_itemsEmptyLabel); var items = AssetHelper.GetAssetList <Item>(false, false); for (var i = 0; i < items.Assets.Count; i++) { if (items.Assets[i] != null) { _addMenu.AddItem(items.Names[i], false, AddItem, items.Assets[i]); } } }