When I ADD:
public GameObject playerPrefab;
According to burgzergarcade.com
playerPrefab should be their in the character generator script to main camera.
When I try to do it along with him it is not displayed.
The CharacterGenerator script is:
using UnityEngine;
using System.Collections;
using System; //used for the enum class
public class CharacterGenerator : MonoBehaviour {
# region PRIVATES
private PlayerCharacter _toon;
private const int Starting_Points = 350;
private const int MIN_STARTING_ATTRIBUTE_VALUE = 10;
private const int STRARTING_VALUE = 50;
private int pointsleft;
private const int OFFSET = 5;
private const int LINE_HEIGHT = 20;
private const int STAT_LABEL_WIDTH = 110;
private const int BASEVALUE_LABEL_WIDTH = 30;
private const int BUTTON_WIDTH = 20;
private const int BUTTON_HEIGHT = 20;
private int STAT_STARTING_POS = 40;
public GUIStyle mystyle;
public GameObject playerPrefab;
#endregion
void Start()
{
Instantiate(player_Prefab, Vector3.zero, Quaternion.identity);
_toon = new PlayerCharacter();
_toon.Awake();
pointsleft = Starting_Points;
for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++){
_toon.GetPrimaryAttribute(cnt).BaseValue = STRARTING_VALUE;
pointsleft -= (STRARTING_VALUE - MIN_STARTING_ATTRIBUTE_VALUE);
}
}
void Update(){
_toon.StatUpdate();
}
void OnGUI(){
DisplayName();
DisplayPointsleft();
DisplayAttribute();
DisplayVitals();
DispalySkills();
}
private void DisplayName(){
GUI.Label(new Rect(10, 10, 50, 25), "Name:");
_toon.Name = GUI.TextField(new Rect(65, 10, 100, 25), _toon.Name);
}
private void DisplayAttribute(){
#region Display
for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++){
GUI.Label(new Rect(OFFSET, //x
STAT_STARTING_POS +(cnt* LINE_HEIGHT), //y
STAT_LABEL_WIDTH, //width
LINE_HEIGHT), //height
((AttributeName)cnt).ToString(), mystyle );
GUI.Label(new Rect(STAT_LABEL_WIDTH + OFFSET, //x
STAT_STARTING_POS +(cnt* LINE_HEIGHT), //y
BASEVALUE_LABEL_WIDTH, //width
LINE_HEIGHT), //height
_toon.GetPrimaryAttribute(cnt).AddjustedBaseValue.ToString(), mystyle);
#endregion
#region Button
if(GUI.Button(new Rect(OFFSET + STAT_LABEL_WIDTH + BASEVALUE_LABEL_WIDTH, //x
STAT_STARTING_POS +(cnt* BUTTON_HEIGHT), //y
BUTTON_WIDTH, //width
BUTTON_HEIGHT), //height
"-", mystyle)){
if(_toon.GetPrimaryAttribute(cnt).BaseValue > MIN_STARTING_ATTRIBUTE_VALUE) {
_toon.GetPrimaryAttribute(cnt).BaseValue--;
pointsleft++;
}
}
if(GUI.Button(new Rect(OFFSET + STAT_LABEL_WIDTH + BASEVALUE_LABEL_WIDTH + BUTTON_WIDTH , //x
STAT_STARTING_POS +(cnt* BUTTON_HEIGHT), //y
BUTTON_WIDTH, //width
BUTTON_HEIGHT),
"+", mystyle)){ //height
if(pointsleft > 0) {
_toon.GetPrimaryAttribute(cnt).BaseValue++;
pointsleft--;
}
}
}
}
#endregion
private void DisplayVitals(){
for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++){
GUI.Label(new Rect(OFFSET,
STAT_STARTING_POS + ((cnt + 7) * LINE_HEIGHT), //x
STAT_LABEL_WIDTH, //y
LINE_HEIGHT), //width
((VitalName)cnt).ToString(),mystyle ); //height
GUI.Label(new Rect(OFFSET + STAT_LABEL_WIDTH, //x
STAT_STARTING_POS + ((cnt + 7) * LINE_HEIGHT), //y
BASEVALUE_LABEL_WIDTH, //width
LINE_HEIGHT), //height
_toon.GetPrimaryAttribute(cnt).AddjustedBaseValue.ToString(), mystyle);
}
}
private void DispalySkills(){
for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++){
GUI.Label(new Rect(OFFSET + STAT_LABEL_WIDTH + BASEVALUE_LABEL_WIDTH + BUTTON_WIDTH * 2 + OFFSET * 2, //x
STAT_STARTING_POS + (cnt * LINE_HEIGHT), //y
STAT_LABEL_WIDTH, //width
LINE_HEIGHT), //height
((SkillName)cnt).ToString(), mystyle );
GUI.Label(new Rect(OFFSET + STAT_LABEL_WIDTH + BASEVALUE_LABEL_WIDTH + BUTTON_WIDTH * 2 + OFFSET * 2 + STAT_LABEL_WIDTH, //x
STAT_STARTING_POS + (cnt * LINE_HEIGHT), //y
BASEVALUE_LABEL_WIDTH, //width
LINE_HEIGHT), //height
_toon.GetPrimaryAttribute(cnt).AddjustedBaseValue.ToString(),mystyle);
}
}
private void DisplayPointsleft(){
GUI.Label(new Rect(250, 10, 100, 25), "Points Left: " + pointsleft.ToString(),mystyle);
}
}
can someone help me
I suggest you watch his video