5-16 Character Property Panel
![圖片](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwpM_SUZ89Xj5bqg_76WOzUCvZO_GzZesk5r-6be-GZhUTrFEjjiGX1qEwDD2Vh3A1liLYVYIkVxgTNymZ8f7qpjlSpqbFyS6WUMIUxvvdP7FbW0Bkv8lBmJc9IN5G5ULejD-n2SothmVt/s640/%25E8%259E%25A2%25E5%25B9%2595%25E5%25BF%25AB%25E7%2585%25A7+2018-01-31+%25E4%25B8%258B%25E5%258D%25888.15.52.png)
本章要來講講顯示人物屬性的視窗,主要是從背包內裝上裝備後,必須要更新人物屬性數值。首先,讓我們在Character Panel中新增一個UI/Panel。 新的Panel取名為Property Panel,然後在底下新增一個UI/Text,這是要用來顯示人數屬性的。 然後,Text的Anchor Presets請設定成stretch stretch。 然後請大家自己調整一下文字的大小、顏色。 最後,大致上做成如下圖的模樣,Property Panel的背景底圖就請大家自己找找吧。 接著,新增一個Script名為CharacterProperty.cs。 CharacterProperty.cs的原始碼如下: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace RPG.Inventory{ public class CharacterProperty : MonoBehaviour { [SerializeField] int baseStrength = 10; [SerializeField] int baseIntellect = 10; [SerializeField] int baseAgility = 10; [SerializeField] int baseStamina = 10; Text propertyText; InventorySystem inventorySystem; void Start(){ propertyText = GetComponent (); inventorySystem = GetComponentInParent (); } public void UpdatePropertyText(){ int strength = 0; int intellect = 0; int agility = 0; int stamina = 0; Slot[] slotList = inventorySystem.G...