0
我將如何獲得mainChars統計信息顯示在檢查員?將統計信息顯示在檢查器中?
using UnityEngine;
using System.Collections;
public class BaseStats : MonoBehaviour {
public struct baseStats {
public string name;
public int currentLevel;
public int targetLevel;
public int currentHp;
public int maxHp;
public int currentAp;
public int maxAp;
public int strength;
public int toughness;
public int agility;
public int intelligence;
public int willPower;
public int luck;
public int attack;
public int hitPercentage;
public int defence;
public int evasionPercentage;
public int abilityAttack;
public int abilityDefence;
public int abilityDefencePercentage;
public int currentExp;
public int targetExp;
public baseStats(string Name, int CurrentLevel, int TargetLevel, int CurrentHp, int MaxHp, int CurrentAp, int MaxAp, int Strength, int Toughness, int Agility, int Intelligence, int WillPower, int Luck, int Attack, int HitPercentage, int Defence, int EvasionPercentage, int AbilityAttack, int AbilityDefence, int AbilityDefencePercentage, int CurrentExp, int TargetExp) {
name = Name;
currentLevel = CurrentLevel;
targetLevel = TargetLevel;
currentHp = CurrentHp;
maxHp = MaxHp;
currentAp = CurrentAp;
maxAp = MaxAp;
strength = Strength;
toughness = Toughness;
agility = Agility;
intelligence = Intelligence;
willPower = WillPower;
luck = Luck;
attack = Attack;
hitPercentage = HitPercentage;
defence = Defence;
evasionPercentage = EvasionPercentage;
abilityAttack = AbilityAttack;
abilityDefence = AbilityDefence;
abilityDefencePercentage = AbilityDefencePercentage;
currentExp = CurrentExp;
targetExp = TargetExp;
}
}
void Start() {
baseStats mainChar = new baseStats(
"Truth",
98,
99,
7554,
9999,
754,
999,
255,
255,
255,
255,
255,
255,
255,
255,
255,
100,
255,
255,
100,
7773473,
7777777);
print(mainChar.currentHp);
}
}
我想要它,我可以讓每個角色在檢查員的下拉列表中。此外,我希望它可以代替使hp成爲當前和最大值,也可以使每個字符的下拉列表包含當前和最大值,對於ap和exp也是如此。先謝謝了!!!
很酷的工作表示感謝!我如何得到實際值顯示,它只顯示0的一切。我應該把公共baseStats mainChar;在啓動功能? – user2279258
當您運行預覽時,這些值將更改爲您在「Start()」函數中分配的值。在啓動函數中分配值的唯一問題是它們將始終覆蓋您在檢查器中設置的值。由於您在檢查器中設置了值,因此可以從'Start'中刪除baseStats構造函數,並將這些值複製到檢查器中的字段中。這些值將會保存。 – Jerdak
它永遠不會改變爲我分配的D:哦,我想我會生病繼續嘗試的東西......儘管如此謝謝! – user2279258