Quantcast
Channel: Latest Questions by Flowered
Viewing all articles
Browse latest Browse all 20

Create a Playername on new UI System

$
0
0
Hello! I have an InputField with a child 'Text' on it. When I press Play and write anything into that Text, and I click on Create, I get this error: NullReferenceException: Object reference not set to an instance of an object Here is my code: private Text playerName; public void CreateCharacterButton(){ playerName = transform.FindChild ("EnterNameButton").FindChild("InputField").FindChild("EnterNameText").GetComponent (); //when using this, I get a "Cannot implicitly convert type `UnityEngine.UI.Text' to `string'" (just btw) // playerName.text = playerName; CreateNewPlayer(); StoreNewPlayerInfo(); SaveInformation.SaveAllInformation(); } private void StoreNewPlayerInfo(){ GameInformation.PlayerName = newPlayer.PlayerName; } void CreateNewPlayer(){ newPlayer.PlayerName = playerName; } } to see code better: http://hastebin.com/kawoyaxubi.cs Does anyone know why it is not working? I attached the script onto my Canvas and childed it till my Text Component of the InputField...

Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>