Update
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2663967159f2ded49a7138ca8a6390d1
|
||||
folderAsset: yes
|
||||
timeCreated: 1487728749
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,216 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Invector.vItemManager
|
||||
{
|
||||
public static class Helper
|
||||
{
|
||||
public static bool NameEquals(this vItemEnumsBuilder.ItemEnumObject a, vItemEnumsBuilder.ItemEnumObject b)
|
||||
{
|
||||
return a.name.Equals(b.name);
|
||||
}
|
||||
public static bool FormatEquals(this vItemEnumsBuilder.ItemEnumObject a, vItemEnumsBuilder.ItemEnumObject b)
|
||||
{
|
||||
return a.format.Equals(b.format);
|
||||
}
|
||||
}
|
||||
public class vItemEnumsBuilder
|
||||
{
|
||||
|
||||
public class ItemEnumObject
|
||||
{
|
||||
public string name;
|
||||
public string format;
|
||||
public ItemEnumObject (string name,string format)
|
||||
{
|
||||
this.name = name;
|
||||
this.format = format;
|
||||
}
|
||||
}
|
||||
public static void RefreshItemEnums()
|
||||
{
|
||||
string name = "vItemEnums";
|
||||
string copyPath = "Assets/Invector-3rdPersonController/ItemManager/Scripts/vItemEnumsBuilder/" + name + ".cs";
|
||||
|
||||
vItemEnumsList[] datas = Resources.LoadAll<vItemEnumsList>("");
|
||||
List<string> defaultItemTypeNames = new List<string>();
|
||||
List<string> defaultItemAttributesNames = new List<string>();
|
||||
List<string> _itemTypeNames = new List<string>();
|
||||
List<string> _itemAttributeNames = new List<string>();
|
||||
List<string> _itemTypeFormats = new List<string>();
|
||||
List<string> _itemAttributeFormats = new List<string>();
|
||||
#region Get all vItemType values of current Enum
|
||||
try
|
||||
{
|
||||
_itemTypeNames = Enum.GetNames(typeof(vItemType)).vToList();
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Get all vItemAttributes values of current Enum
|
||||
try
|
||||
{
|
||||
_itemAttributeNames = Enum.GetNames(typeof(vItemAttributes)).vToList();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (datas != null)
|
||||
{
|
||||
#region Get all enum of ItemEnumList
|
||||
for (int i = 0; i < datas.Length; i++)
|
||||
{
|
||||
if (datas[i].itemTypeEnumValues != null)
|
||||
{
|
||||
|
||||
for (int a = 0; a < datas[i].itemTypeEnumValues.Count; a++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(datas[i].itemTypeEnumValues[a]) && !defaultItemTypeNames.Contains(datas[i].itemTypeEnumValues[a]))
|
||||
{
|
||||
|
||||
defaultItemTypeNames.Add(datas[i].itemTypeEnumValues[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (datas[i].itemAttributesEnumValues != null)
|
||||
{
|
||||
for (int a = 0; a < datas[i].itemAttributesEnumValues.Count; a++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(datas[i].itemAttributesEnumValues[a]) && !defaultItemAttributesNames.Contains(datas[i].itemAttributesEnumValues[a]))
|
||||
{
|
||||
defaultItemAttributesNames.Add(datas[i].itemAttributesEnumValues[a]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string value in defaultItemTypeNames)
|
||||
{
|
||||
if (!_itemTypeNames.Contains(value))
|
||||
{
|
||||
bool replace = false;
|
||||
for (int i = 0; i < _itemTypeNames.Count; i++)
|
||||
{
|
||||
if (!defaultItemTypeNames.Contains(_itemTypeNames[i]))
|
||||
{
|
||||
replace = true;
|
||||
_itemTypeNames[i] = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!replace)
|
||||
_itemTypeNames.Add(value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Remove enum that not exist
|
||||
var typesToRemove = _itemTypeNames.FindAll(x => !defaultItemTypeNames.Contains(x));
|
||||
foreach (string value in typesToRemove)
|
||||
_itemTypeNames.Remove(value);
|
||||
|
||||
foreach (string value in defaultItemAttributesNames)
|
||||
{
|
||||
if (!_itemAttributeNames.Contains(value))
|
||||
{
|
||||
bool replace = false;
|
||||
for (int i = 0; i < _itemAttributeNames.Count; i++)
|
||||
{
|
||||
if (!defaultItemAttributesNames.Contains(_itemAttributeNames[i]))
|
||||
{
|
||||
replace = true;
|
||||
_itemAttributeNames[i] = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!replace)
|
||||
_itemAttributeNames.Add(value);
|
||||
}
|
||||
}
|
||||
var attributesToRemove = _itemAttributeNames.FindAll(x => !defaultItemAttributesNames.Contains(x));
|
||||
foreach (string value in attributesToRemove)
|
||||
_itemAttributeNames.Remove(value);
|
||||
#endregion
|
||||
|
||||
|
||||
#region Get Enum Text Formats
|
||||
for(int i =0;i< _itemTypeNames.Count;i++)
|
||||
{
|
||||
vItemEnumsList data = datas.vToList().Find(d => d.itemTypeEnumValues.Contains(_itemTypeNames[i]));
|
||||
if(data!=null)
|
||||
{
|
||||
var index = data.itemTypeEnumValues.IndexOf(_itemTypeNames[i]);
|
||||
if(index<data.itemTypeEnumFormats.Count)
|
||||
{
|
||||
_itemTypeFormats.Add(data.itemTypeEnumFormats[index]);
|
||||
}
|
||||
else
|
||||
_itemTypeFormats.Add("");
|
||||
}
|
||||
else _itemTypeFormats.Add("");
|
||||
}
|
||||
|
||||
for (int i = 0; i < _itemAttributeNames.Count; i++)
|
||||
{
|
||||
vItemEnumsList data = datas.vToList().Find(d => d.itemAttributesEnumValues.Contains(_itemAttributeNames[i]));
|
||||
if (data != null)
|
||||
{
|
||||
var index = data.itemAttributesEnumValues.IndexOf(_itemAttributeNames[i]);
|
||||
if (index < data.itemAttributesEnumFormats.Count)
|
||||
{
|
||||
_itemAttributeFormats.Add(data.itemAttributesEnumFormats[index]);
|
||||
}
|
||||
else
|
||||
_itemAttributeFormats.Add("");
|
||||
}
|
||||
else _itemAttributeFormats.Add("");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
CreateEnumClass(copyPath, _itemTypeNames, _itemAttributeNames,_itemTypeFormats,_itemAttributeFormats);
|
||||
}
|
||||
|
||||
static void CreateEnumClass(string copyPath, List<string> itemTypes = null, List<string> itemAttributes = null,
|
||||
List<string> itemTypesFormat = null, List<string> itemAttributesFormat = null)
|
||||
{
|
||||
if (File.Exists(copyPath)) File.Delete(copyPath);
|
||||
using (StreamWriter outfile = new StreamWriter(copyPath))
|
||||
{
|
||||
outfile.WriteLine("using System.ComponentModel;");
|
||||
outfile.WriteLine("namespace Invector.vItemManager {");
|
||||
outfile.WriteLine(" public enum vItemType {");
|
||||
if (itemTypes != null)
|
||||
{
|
||||
for (int i = 0; i < itemTypes.Count; i++)
|
||||
{
|
||||
outfile.WriteLine(" "+string.Format("[Description(\"{0}\")] ",itemTypesFormat[i]) + itemTypes[i] + "=" + i + (i == itemTypes.Count - 1 ? "" : ","));
|
||||
}
|
||||
}
|
||||
outfile.WriteLine(" }");
|
||||
outfile.WriteLine(" public enum vItemAttributes {");
|
||||
if (itemAttributes != null)
|
||||
{
|
||||
for (int i = 0; i < itemAttributes.Count; i++)
|
||||
{
|
||||
outfile.WriteLine(" " + string.Format("[Description(\"{0}\")] ", itemAttributesFormat[i]) + itemAttributes[i] + "=" + i + (i == itemAttributes.Count - 1 ? "" : ","));
|
||||
}
|
||||
}
|
||||
outfile.WriteLine(" }");
|
||||
outfile.WriteLine("}");
|
||||
}
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2100ee3b5c97dd84dbadcc20c6a285fc
|
||||
timeCreated: 1487717080
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,243 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Invector.vItemManager.DynamicEnum
|
||||
{
|
||||
|
||||
[CustomEditor(typeof(vItemEnumsList))]
|
||||
public class vItemEnumsListEditor : UnityEditor.Editor
|
||||
{
|
||||
public GUISkin skin;
|
||||
public float fieldWidht = 0;
|
||||
|
||||
public GUIStyle placeholderTextStyle;
|
||||
void OnEnable()
|
||||
{
|
||||
skin = Resources.Load("vSkin") as GUISkin;
|
||||
vItemEnumsList list = (vItemEnumsList)target;
|
||||
serializedObject.FindProperty("itemTypeEnumFormats").arraySize = serializedObject.FindProperty("itemTypeEnumValues").arraySize;
|
||||
for (int i=0;i<list.itemTypeEnumValues.Count;i++)
|
||||
{
|
||||
vItemType t;
|
||||
if(Enum.TryParse<vItemType>(list.itemTypeEnumValues[i],out t))
|
||||
{
|
||||
list.itemTypeEnumFormats[i] = t.DisplayFormat();
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.FindProperty("itemAttributesEnumFormats").arraySize = serializedObject.FindProperty("itemAttributesEnumValues").arraySize;
|
||||
for (int i = 0; i < list.itemAttributesEnumValues.Count; i++)
|
||||
{
|
||||
vItemAttributes t;
|
||||
if (Enum.TryParse<vItemAttributes>(list.itemAttributesEnumValues[i], out t))
|
||||
{
|
||||
list.itemAttributesEnumFormats[i] = t.DisplayFormat();
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (skin) GUI.skin = skin;
|
||||
serializedObject.Update();
|
||||
var assetPath = AssetDatabase.GetAssetPath(target);
|
||||
GUILayout.BeginVertical("vItemEnums List", "window");
|
||||
GUILayout.Space(30);
|
||||
if (assetPath.Contains("Resources"))
|
||||
{
|
||||
GUILayout.BeginVertical("box");
|
||||
EditorGUILayout.HelpBox("**Format : Rich Text Format usage to create custom text format to display the Item Enums in the inventory like a\n" +
|
||||
" Special Tags : (NAME) : dipllay name of the Enum\n" +
|
||||
" (VALUE): display value of the Attribute (only for Item Attribute Enum)\n" +
|
||||
"Keep Format empty to use Default display", MessageType.Info);
|
||||
DrawEnumList();
|
||||
GUILayout.EndHorizontal();
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Open ItemEnums Editor"))
|
||||
{
|
||||
vItemEnumsWindow.CreateWindow();
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Refresh ItemEnums"))
|
||||
{
|
||||
vItemEnumsBuilder.RefreshItemEnums();
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox("-This list will be merged with other lists and create the enums.\n- The Enum Generator will ignore equal values.\n- If our change causes errors, check which enum value is missing and adds to the list and press the refresh button.", MessageType.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox("Please put this list in Resources folder", MessageType.Warning);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
public delegate bool NameCompare(string compare);
|
||||
public delegate bool DescriptionCompare(string name,string compare);
|
||||
public void DrawEnumList()
|
||||
{
|
||||
var typeNameCompare = new NameCompare(CompareItemTypeName);
|
||||
var typeDescriptionCompare = new DescriptionCompare(CompareItemTypeDescription);
|
||||
var attrNameCompare = new NameCompare(CompareItemAttbiuteName);
|
||||
var attrDescriptionCompare = new DescriptionCompare(CompareItemAttributeDescription);
|
||||
DrawList(serializedObject.FindProperty("itemTypeEnumValues"), serializedObject.FindProperty("itemTypeEnumFormats"),typeNameCompare,typeDescriptionCompare);
|
||||
DrawList(serializedObject.FindProperty("itemAttributesEnumValues"), serializedObject.FindProperty("itemAttributesEnumFormats"),attrNameCompare,attrDescriptionCompare);
|
||||
}
|
||||
|
||||
bool CompareItemTypeName(string compare)
|
||||
{
|
||||
vItemType t;
|
||||
|
||||
if (Enum.TryParse<vItemType>(compare, out t)) return true;
|
||||
else return false;
|
||||
|
||||
}
|
||||
|
||||
bool CompareItemTypeDescription(string name, string compare)
|
||||
{
|
||||
vItemType t;
|
||||
|
||||
if (Enum.TryParse<vItemType>(name, out t))
|
||||
{
|
||||
return string.IsNullOrEmpty(t.DisplayFormat())&& string.IsNullOrEmpty(compare)|| t.DisplayFormat().Equals(compare);
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool CompareItemAttbiuteName(string compare)
|
||||
{
|
||||
vItemAttributes t;
|
||||
|
||||
if (Enum.TryParse<vItemAttributes>(compare, out t)) return true;
|
||||
else return false;
|
||||
|
||||
}
|
||||
|
||||
bool CompareItemAttributeDescription(string name, string compare)
|
||||
{
|
||||
vItemAttributes t;
|
||||
|
||||
if (Enum.TryParse<vItemAttributes>(name, out t))
|
||||
{
|
||||
return string.IsNullOrEmpty(t.DisplayFormat()) && string.IsNullOrEmpty(compare) || t.DisplayFormat().Equals(compare);
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
public override bool UseDefaultMargins()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void DrawList(SerializedProperty nameList,SerializedProperty nameFormatList,NameCompare compareName,DescriptionCompare compareDescription)
|
||||
{
|
||||
|
||||
GUILayout.BeginVertical("box");
|
||||
{
|
||||
GUILayout.Box(nameList.displayName, GUILayout.ExpandWidth(true));
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
|
||||
GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
|
||||
{
|
||||
GUI.color = Color.white;
|
||||
GUILayout.Box("Name", GUILayout.ExpandWidth(true));
|
||||
for (int i = 0; i < nameList.arraySize; i++)
|
||||
{
|
||||
SerializedProperty name = nameList.GetArrayElementAtIndex(i);
|
||||
GUI.color = compareName(name.stringValue)? Color.grey: Color.white;
|
||||
EditorGUILayout.PropertyField(name, GUIContent.none, GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight));
|
||||
InsertPlaceHolder(name.stringValue, new GUIContent("...Enum Name"));
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
|
||||
{
|
||||
if (nameList.arraySize != nameFormatList.arraySize) nameFormatList.arraySize = nameList.arraySize;
|
||||
GUI.color = Color.white;
|
||||
GUILayout.Box("Format", GUILayout.ExpandWidth(true));
|
||||
for (int i = 0; i < nameFormatList.arraySize; i++)
|
||||
{
|
||||
SerializedProperty format = nameFormatList.GetArrayElementAtIndex(i);
|
||||
string name = nameList.GetArrayElementAtIndex(i).stringValue;
|
||||
GUI.color = compareDescription(name, format.stringValue) ? Color.grey : Color.white;
|
||||
EditorGUILayout.PropertyField(format, GUIContent.none,GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight));
|
||||
InsertPlaceHolder(format.stringValue, new GUIContent("... Rich Text Format"));
|
||||
GUI.color=Color.white;
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical(GUILayout.Width(20));
|
||||
{
|
||||
if (GUILayout.Button("+", "box", GUILayout.Width(20)))
|
||||
{
|
||||
Undo.RecordObject(serializedObject.targetObject, "ChangeArraySize");
|
||||
nameList.arraySize++;
|
||||
nameFormatList.arraySize++;
|
||||
}
|
||||
for (int i = 0; i < nameList.arraySize; i++)
|
||||
{
|
||||
if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(20), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
|
||||
{
|
||||
Undo.RecordObject(serializedObject.targetObject, "RemoveElement");
|
||||
nameList.DeleteArrayElementAtIndex(i);
|
||||
nameFormatList.DeleteArrayElementAtIndex(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
bool ItemTypesContainsDescription(string enumName,string description)
|
||||
{
|
||||
vItemType e = enumName.ToEnum<vItemType>();
|
||||
|
||||
return e.DisplayFormat().Equals(description);
|
||||
}
|
||||
|
||||
bool ItemAttributesContainsDescription(string enumName, string description)
|
||||
{
|
||||
vItemAttributes e = enumName.ToEnum<vItemAttributes>();
|
||||
|
||||
return e.DisplayFormat().Equals(description);
|
||||
}
|
||||
|
||||
void InsertPlaceHolder(string originalText,GUIContent placeHolderText)
|
||||
{
|
||||
if(placeholderTextStyle==null)
|
||||
{
|
||||
placeholderTextStyle = new GUIStyle(EditorStyles.label);
|
||||
placeholderTextStyle.fontStyle = FontStyle.Italic;
|
||||
placeholderTextStyle.wordWrap = true;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(originalText))
|
||||
{
|
||||
GUILayout.Space(-(EditorGUIUtility.singleLineHeight+ 2.5f));
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
GUILayout.Label(placeHolderText, placeholderTextStyle, GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight));
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
}
|
||||
|
||||
[MenuItem("Invector/Inventory/ItemEnums/Create New vItemEnumsList")]
|
||||
internal static void CreateDefaultItemEnum()
|
||||
{
|
||||
vScriptableObjectUtility.CreateAsset<vItemEnumsList>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f82d672b18876b545aa4f1d8a7f24215
|
||||
timeCreated: 1487687754
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 700e1b72ce748a848a915eff6958d4db
|
||||
folderAsset: yes
|
||||
timeCreated: 1487695925
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 68fa35b27a7967c4a94bcc4596c2aef1, type: 3}
|
||||
m_Name: vItemEnumsList
|
||||
m_EditorClassIdentifier:
|
||||
itemTypeEnumValues:
|
||||
- Consumable
|
||||
- Builder
|
||||
itemAttributesEnumValues:
|
||||
- Health
|
||||
- MaxHealth
|
||||
- MaxStamina
|
||||
- Stamina
|
||||
itemTypeEnumFormats:
|
||||
-
|
||||
-
|
||||
itemAttributesEnumFormats:
|
||||
-
|
||||
-
|
||||
-
|
||||
-
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1d418c4d0b4ab440b62371eb60d8c56
|
||||
timeCreated: 1487713007
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
public static class vInventoryDisplayFormat
|
||||
{
|
||||
static readonly List<string> ItemTypeFormats = new List<string>();
|
||||
static readonly List<string> ItemAttributeFormats = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Get Item type string format using Description in <seealso cref="Invector.vItemManager.vItemType"/> value
|
||||
/// </summary>
|
||||
/// <param name="value">target Item type</param>
|
||||
/// <returns></returns>
|
||||
public static string DisplayFormat(this Invector.vItemManager.vItemType value)
|
||||
{
|
||||
if (ItemTypeFormats.Count == 0)
|
||||
{
|
||||
|
||||
var values = System.Enum.GetValues(typeof(Invector.vItemManager.vItemType)).OfType<Invector.vItemManager.vItemType>().ToArray();
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
Invector.vItemManager.vItemType v = values[i];
|
||||
ItemTypeFormats.Add(GetDisplayFormat(v));
|
||||
}
|
||||
}
|
||||
return ItemTypeFormats[(int)value];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Item Attribute string format using Description in <seealso cref="Invector.vItemManager.vItemAttributes"/> value
|
||||
/// </summary>
|
||||
/// <param name="value">target Item Attribute</param>
|
||||
/// <returns></returns>
|
||||
public static string DisplayFormat(this Invector.vItemManager.vItemAttributes value)
|
||||
{
|
||||
if (ItemAttributeFormats.Count == 0)
|
||||
{
|
||||
var values = System.Enum.GetValues(typeof(Invector.vItemManager.vItemAttributes)).OfType<Invector.vItemManager.vItemAttributes>().ToArray();
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
Invector.vItemManager.vItemAttributes v = values[i];
|
||||
ItemAttributeFormats.Add(GetDisplayFormat(v));
|
||||
}
|
||||
}
|
||||
return ItemAttributeFormats[(int)value];
|
||||
}
|
||||
|
||||
static string GetDisplayFormat<T>(this T value) where T : System.Enum
|
||||
{
|
||||
return
|
||||
value
|
||||
.GetType()
|
||||
.GetMember(value.ToString())
|
||||
.FirstOrDefault()
|
||||
?.GetCustomAttribute<DescriptionAttribute>()
|
||||
?.Description
|
||||
?? value.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44c5bf43846e6ce43a9516467112de39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.ComponentModel;
|
||||
namespace Invector.vItemManager {
|
||||
public enum vItemType {
|
||||
[Description("")] Consumable=0,
|
||||
[Description("Melee")] MeleeWeapon=1,
|
||||
[Description("Shooter")] ShooterWeapon=2,
|
||||
[Description("(VALUE)")] Ammo=3,
|
||||
[Description("")] Archery=4,
|
||||
[Description("")] Builder=5,
|
||||
[Description("")] Defense=6,
|
||||
[Description("")] CraftingMaterials=7
|
||||
}
|
||||
public enum vItemAttributes {
|
||||
[Description("")] Health=0,
|
||||
[Description("")] Stamina=1,
|
||||
[Description("<i>Damage</i> : <color=red>(VALUE)</color>")] Damage=2,
|
||||
[Description("")] StaminaCost=3,
|
||||
[Description("")] DefenseRate=4,
|
||||
[Description("")] DefenseRange=5,
|
||||
[Description("(VALUE)")] AmmoCount=6,
|
||||
[Description("")] MaxHealth=7,
|
||||
[Description("")] MaxStamina=8,
|
||||
[Description("(VALUE)")] SecundaryAmmoCount=9,
|
||||
[Description("")] SecundaryDamage=10,
|
||||
[Description("")] CanCraftItemID=11
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3f14f7e759359347b5b39665dce88f6
|
||||
timeCreated: 1487729615
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
namespace Invector.vItemManager
|
||||
{
|
||||
public class vItemEnumsList : ScriptableObject
|
||||
{
|
||||
[SerializeField, HideInInspector]
|
||||
public List<string> itemTypeEnumValues = new List<string>();
|
||||
[SerializeField, HideInInspector]
|
||||
public List<string> itemAttributesEnumValues = new List<string>();
|
||||
|
||||
[SerializeField, HideInInspector]
|
||||
public List<string> itemTypeEnumFormats = new List<string>();
|
||||
[SerializeField, HideInInspector]
|
||||
public List<string> itemAttributesEnumFormats = new List<string>();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68fa35b27a7967c4a94bcc4596c2aef1
|
||||
timeCreated: 1487694466
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user