public override void OnInspectorGUI()
 {
     if (enemy)
     {
         EnemyHeader();
     }
     else if (NPC)
     {
         NPCInfoHeader();
     }
     else if (string.IsNullOrEmpty(character.Name) || string.IsNullOrEmpty(character.ID))
     {
         EditorGUILayout.HelpBox("该角色信息未补全。", MessageType.Warning);
     }
     else
     {
         EditorGUILayout.HelpBox("该角色信息已完整。", MessageType.Info);
     }
     if (!NPC)
     {
         serializedObject.UpdateIfRequiredOrScript();
         EditorGUI.BeginChangeCheck();
         EditorGUILayout.PropertyField(_ID, new GUIContent("识别码"));
         if (string.IsNullOrEmpty(_ID.stringValue) || ExistsID())
         {
             if (!string.IsNullOrEmpty(_ID.stringValue) && ExistsID())
             {
                 EditorGUILayout.HelpBox("此识别码已存在!", MessageType.Error);
             }
             else
             {
                 EditorGUILayout.HelpBox("识别码为空!", MessageType.Error);
             }
             if (GUILayout.Button("自动生成识别码"))
             {
                 _ID.stringValue = GetAutoID();
                 EditorGUI.FocusTextInControl(null);
             }
         }
         EditorGUILayout.PropertyField(_name, new GUIContent("名称"));
         if (EditorGUI.EndChangeCheck())
         {
             serializedObject.ApplyModifiedProperties();
         }
         if (enemy)
         {
             DrawEnemyInfo();
         }
         else if (player)
         {
             serializedObject.UpdateIfRequiredOrScript();
             EditorGUI.BeginChangeCheck();
             EditorGUILayout.PropertyField(SMParams, new GUIContent("状态机参数"));
             if (EditorGUI.EndChangeCheck())
             {
                 serializedObject.ApplyModifiedProperties();
             }
             serializedObject.UpdateIfRequiredOrScript();
             attrDrawer.DoLayoutDraw();
             serializedObject.ApplyModifiedProperties();
         }
     }
     else
     {
         DrawNPCInfo();
     }
 }
Exemple #2
0
    void HandlingItemType()
    {
        switch (item.ItemType)
        {
        case ItemType.Medicine:

            break;

        case ItemType.Weapon:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("gemSlotAmount"), new GUIContent("默认宝石槽数"));
            goto case ItemType.Gemstone;

        case ItemType.Armor:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("armorType"), new GUIContent("防具类型"));

            EditorGUILayout.PropertyField(serializedObject.FindProperty("gemSlotAmount"), new GUIContent("默认宝石槽数"));
            goto case ItemType.Gemstone;

        case ItemType.Gemstone:
            //EditorGUILayout.PropertyField(serializedObject.FindProperty("powerup"), new GUIContent("附加效果"), true);
            break;

        case ItemType.Book:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("bookType"), new GUIContent("书籍/图纸类型"), true);
            switch ((item as BookItem).BookType)
            {
            case BookType.Building:
                SerializedProperty building = serializedObject.FindProperty("buildingToLearn");
                EditorGUILayout.PropertyField(building, new GUIContent("可学设施"), true);
                if (building.objectReferenceValue)
                {
                    EditorGUILayout.LabelField("设施名称", (building.objectReferenceValue as StructureInformation).Name);
                }
                break;

            case BookType.Making:
                SerializedProperty item = serializedObject.FindProperty("itemToLearn");
                EditorGUILayout.PropertyField(item, new GUIContent("可学道具"), true);
                if (item.objectReferenceValue)
                {
                    if ((item.objectReferenceValue as ItemBase).MakingMethod == MakingMethod.None)
                    {
                        EditorGUILayout.HelpBox("不可制作的道具!", MessageType.Error);
                    }
                    else
                    {
                        EditorGUILayout.LabelField("道具名称", (item.objectReferenceValue as ItemBase).Name);
                    }
                }
                break;

            default: break;
            }
            break;

        case ItemType.Bag:
            serializedObject.FindProperty("expandSize").intValue = EditorGUILayout.IntSlider(new GUIContent("背包扩张数量"), serializedObject.FindProperty("expandSize").intValue, 1, 192);
            break;

        case ItemType.Quest:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("triggerName"), new GUIContent("触发器名称"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("stateToSet"), new GUIContent("触发器状态"));
            break;

        case ItemType.Seed:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("crop"), new GUIContent("农作物信息"));
            break;

        case ItemType.Currency:
            EditorGUILayout.PropertyField(serializedObject.FindProperty("currencyType"), new GUIContent("货币类型"));
            break;

        default: break;
        }
        if (item.IsEquipment)
        {
            EditorGUILayout.PropertyField(attribute, new GUIContent("装备属性"), false);
            if (attribute.isExpanded)
            {
                attrDrawer?.DoLayoutDraw();
            }
            EditorGUILayout.PropertyField(maxDurability, new GUIContent("最大耐久度"));
            if (maxDurability.intValue < 1)
            {
                maxDurability.intValue = 1;
            }
        }
        else if (item.IsCurrency)
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("valueEach"), new GUIContent("面额"));
        }
    }