#could anyone tell me how i could make it so that, you as a player, can change the values of a field
1 messages · Page 1 of 1 (latest)
this is my code
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dogMaker : MonoBehaviour
{
public class dog
{
public string name;
public int age;
public string race;
public dog(string _name, int _age, string _race)
{
name = _name;
age = _age;
race = _race;
}
}
public dog dog1 = new dog("Josh", 5 , "German Sheppard");
public void Start()
{
Debug.Log(dog1.name + " has been created with the race set to " + dog1.race + " and is " + dog1.age + " years old.");
}
}
offline in 13min
Just
dog1.name = "...";
...
wdym?
Like you want that the player should give a name to the dog ?
Then for the name you need an input field component on the UI so that the player can enter the name and some scripting.
For the age it needs some some small scripting
For the race some scripting also
That is up to you.
If you use the built-in UI input field (or better the TMP one) though, you will be able to simply enter text with the physical keyboard (or the system keyboard on mobile).
thnx did not know that