Question by
prince1630 · Apr 25, 2019 at 02:47 AM ·
androidscripting problemcanvasresolutionraycasting
UI Appear not appearing after build
Good day! I was trying to make an interaction with some of my objects when the player gaze at the object for 2 secs, an image should appear (screen space - Camera) . However, it is working fine on my Game view and editor but after building it for my android device , image won't appear , I even tried adding a button but had the same problem.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIAppear : MonoBehaviour
{
[SerializeField] private Image customImage;
const float nSecond = 2f;
float timer = 0;
bool entered = false;
void Update()
{
//If pointer is pointing on the object, start the timer
if (entered)
{
//Increment timer
timer += Time.deltaTime;
//Load scene if counter has reached the nSecond
if (timer > nSecond)
{
Debug.Log("Pressed left click.");
customImage.enabled = true;
}
}
else
{
//Reset timer when it's no longer pointing
customImage.enabled = false;
timer = 0;
}
}
public void PointerEnter()
{
entered = true;
}
public void PointerExit()
{
entered = false;
}
void PointerDown()
{
}
}
This is for the Image that will appear
For the trigger
Comment
Your answer
Follow this Question
Related Questions
Possible for 10 canvas in 1 scene? 1 Answer
Some question about making Android game. 0 Answers
Canvas scale 0 Answers
Unity 5.2.2 - Canvas Button, Image, Text - Crashes on Android Immediately 1 Answer