Question by
CaveGames · Jun 05, 2017 at 12:12 AM ·
raycastclickfullscreen
Set Fullscreen With Raycast
Hello! It's me again! Asking the same question as I have for the past week or so, but I feel like I'm getting closer! I'm still having issues though. Here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class FullScreenToggle : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit, 100.0f))
{
//Replace this with whatever logic you want to use to validate the objects you want to click on
if (hit.collider.gameObject.tag == "Toggle")
{
Screen.fullScreen = !Screen.fullScreen;
}
}
}
}
}
The thing has changed since the collider, now no longer clicking, but if anyone has a fix, please tell me.
Comment
Your answer