예제 #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            label = EditorGUI.BeginProperty(position, label, property);

            if (property.propertyType == SerializedPropertyType.ObjectReference)
            {
                Dictionary <string, NPCTypeInfo> npcTypeDic = RTSEditorHelper.GetNPCTypes();

                index = npcTypeDic.Values.ToList().IndexOf(property.objectReferenceValue as NPCTypeInfo);

                if (index < 0) //make sure the index value is always valid
                {
                    index = 0;
                }

                index = EditorGUI.Popup(position, label.text, index, npcTypeDic.Keys.ToArray());

                property.objectReferenceValue = npcTypeDic[npcTypeDic.Keys.ToArray()[index]] as Object;
            }
            else
            {
                EditorGUI.LabelField(position, label.text, "Use [NPCType] with object reference fields.");
            }
        }
예제 #2
0
 public void OnEnable()
 {
     target_SO = new SerializedObject(target as NPCTypeInfo);
     RTSEditorHelper.GetNPCTypes(true, target as NPCTypeInfo);
 }