The question is answered, right answer was accepted
Help with my Title screen - Error CS1023 and Error 0246
I need help with this title screen I'm making for my game. First of all I'm a newbie and I am making this title screen using methods I've gathered from different sources. I keep getting error CS1023 (49,36) and error 0246 (26,9). I don't know whats wrong on line 49 and 26. What this code is basically supposed to do is hide a RawImage on the Canvas upon a keypress so that a different RawImage will be revealed, then when the second RawImage image is being displayed background music should start playing. Also if you see a better method than what I'm doing (or trying to do) please give it to me. The variable names are arbitrary by the way and have no real significance.
using UnityEngine; using System.Collections;
public class splash : MonoBehaviour {
// Use this for initialization
void Start () {
}
private string splashcurr ="notyet";
private string titlestate ="no";
public float splash_count = 4.0f;
private AudioSource source1;
// Update is called once per frame
void Update () {
if (splash_count <= 0.0f)
splashcurr ="summon";
else
splash_count -= Time.deltaTime;
}
// Checks for keypress
function Update() {
if(Input.GetMouseButtonDown(0))
splashcurr ="summon";
if(Input.GetKeyDown (KeyCode.Space)){
if (splashcurr="summon")
splashcurr="ontitle";
else
splashcurr ="summon";
}
if(Input.GetKeyDown (KeyCode.Return))
splashcurr ="summon";
call SplashCheck;
}
// Code for checking and clicking between splashes
void SplashCheck () {
if(splashcurr="summon") {
renderer.enabled=false= Gameobject.Find("IEntertain");
splashcurr ="ontitle";
}
if(splashcurr="ontitle") {
titlestate="now";
Quethemusic;
}
}
void Quethemusic () {
if (titlestate="now")
source1.Play();
}
}
Answer by Dave-Carlile · Sep 08, 2015 at 02:48 PM
=
is the assignment operator, ==
is the comparison operator. Line 49 should be:
if (titlestate == "now")
Same issue on the line 26 error, you're using the assignment operator on line 24 when you mean to use comparison. The compiler isn't sure what you're trying to do so it gives you its best assessment of the problem on a later line.
if (splashcurr=="summon")
Thanks for your help. $$anonymous$$e and my noob mistakes.
Follow this Question
Related Questions
Deleting objects at specific position 1 Answer
Create an object on mouse click? 0 Answers
GameObject Tags 1 Answer
Weapon swap system is not working at all... is there a better way to do this 0 Answers
Change the active value quickly? 1 Answer