Issue with instantiated text clone
The issue is that the temp.sm and various pieces of code that work with the text piece from unity aren't able to figure out that the text piece is equal to surf monkeys even though the debug.log displays the string value for the temp.sm is equal to surf monkeys.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Ink.Runtime;
using UnityEngine.UI;
public class Image : MonoBehaviour {
private SpriteRenderer myImage;
private Text Title;
private string tempSM;
private string QQ = "Surf Monkeys";
// Use this for initialization
void Start () {
myImage = GetComponent<SpriteRenderer>();
myImage.enabled = false;
}
// Update is called once per frame
void Update () {
if (GameObject.Find("Text(Clone)") == null)
{
Debug.Log("returning");
return;
}
else
{
Title = GameObject.Find("Text(Clone)").GetComponent<Text>();
Debug.Log("Found Text");
}
tempSM = Title.text;
Debug.Log("tempSM: " + tempSM);
if (tempSM.Equals(QQ))
{
ImageStatus();
Debug.Log("calling enable imagestat");
}else
{
Debug.Log("not calling enable imagestat");
return;
}
}
public void ImageStatus()
{
var testTempStr = tempSM;
Debug.Log("var test "+ testTempStr);
if ( testTempStr.Equals(QQ))
{
myImage.enabled = true;
Debug.Log("tempSM2: " + tempSM);
}
else
{
myImage.enabled = false;
Debug.Log("tempSM3: " + tempSM);
}
}
}
capture.png
(99.5 kB)
Comment