Hey, I’m completely new to both Unity and C#.
I’m really trying to make a simple 2D scene where the main character walks a small distance and then talks to a NPC at the end of the path. I’ve got a working script for making the main character walk and a working animation for walking. Which means all I need now is a working textbox function… I’ve been looking high and low for about 4 or 5 days now trying to figure out a working way. I’ve gone through countless uinityAnswer pages… Studied all sorts of tutorial pages and videos and this is where I’m at:
using UnityEngine;
using System.Collections;
public class GUIfade : MonoBehaviour {
private string textFieldString = "I love you, Tuba!";
//private string textAreaString = "text area";
public GUISkin customSkin;
public int FadeStart = 150;
public int FadeDist = 5;
//Which items should fade?
public GameObject textbox;
private int FadeEnd;
void textBoxFade ()
{
GUI.skin = customSkin;
GUI.Label (new Rect (720, 650, 1000, 200), textFieldString);
//Check the distance between the active camera and the text
var dist = Vector3.Distance(Camera.main.transform.position, transform.position);
FadeEnd = FadeStart+FadeDist;
//Fade the text and box, with an alpha between 0 and .75
if(dist>FadeStart && dist<FadeEnd){
var renderAlpha = 1-(dist-FadeStart+(.4*FadeDist))/FadeDist;
renderAlpha(customSkin);
Debug.Log(renderAlpha);
}
if(dist>=FadeEnd){
customSkin = 0;
}
if(dist<=FadeStart){
customSkin = 0.75;
}
}
All this checks out but I get an error: “Unexpected symbol ‘end-of-file’”
I’m either looking for a way to solve this code or better code that could get my job done.
Thanks!