Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Rushaaa · Jan 12 at 11:48 PM · canvasrendertexturenewbie

Raw Image or Render Texture block MouseOver (New to unity)

(Btw Im new-ish to unity, only been using it for just over a month) So I have an issue with getting a door to open, and I can imagine this will cause problems with further functions of the game.

I have a code that works perfectly fine, the door opens when the render texture raw image is turned off and the target texture from the camera is removed. However when it is on the prompt to open the door does not appear and the door cannot be opened

Heres the code for the Raycast for the Player:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class PlayerCasting : MonoBehaviour
 {
     public static float DistanceFromTarget;
     public float ToTarget;
 
     
     void Update()
     {
         RaycastHit Hit;
         if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out Hit)) ;
         {
             ToTarget = Hit.distance;
             DistanceFromTarget = ToTarget;
         }
     }
 
 
 }


Heres the code for door:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class DoorOpen: MonoBehaviour
 {
     public float TheDistance;
     public GameObject ActionDisplay;
     public GameObject ActionText;
     public GameObject TheDoor;
     public AudioSource BathroomDoorSound;
 
     void Update()
     {
         TheDistance = PlayerCasting.DistanceFromTarget;
     }
 
     void OnMouseOver ()
     {
         if (TheDistance <= 2)
         {
             ActionDisplay.SetActive (true);
             ActionText.SetActive (true);
         }
 
         if (Input.GetButtonDown("Action"))
         {
             if (TheDistance <= 2)
             {
                 this.GetComponent<BoxCollider>().enabled = false;
                 ActionDisplay.SetActive(false);
                 ActionText.SetActive(false);
                 TheDoor.GetComponent<Animation>().Play("FirstDoorOpen");
                 BathroomDoorSound.Play();
             }
         }
     }
 
     void OnMouseExit()
     {
         ActionDisplay.SetActive(false);
         ActionText.SetActive(false);
     }
 }
 

Thanks for reading, it may be a really easy fix but im not sure and if you need anything else just ask.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by systemicgames · Jan 13 at 08:22 AM

Possibly the Canvas group is blocking raycasts, if you add a Canvas Group to your image and disable Block Raycasts, that might fix it...

https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/class-CanvasGroup.html

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rushaaa · Jan 13 at 01:35 PM 0
Share

Thanks for the information but that doesnt seem to have helped, I already had the canvas group but didnt have the blocking raycast off. However the issue is still occurring.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

142 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Weird Image Flickering Behavior on UI Canvas When Using RT Material 1 Answer

Help with Raycast on Render Texture 0 Answers

Unity RenderTexture with RawImage is black (iOS) 1 Answer

Tutorial dark overlay with cutouts 0 Answers

Need to send Secondary camera render from unity webgl to HTML5 canvas 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges