• 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 Noxury · Oct 11, 2015 at 12:01 AM · uicanvasbuttonseventsysteminterface

Canvas-prefab elements are not interactable

Hello,

My game consists of multiple scenes (levels) and to keep the size more less and to save time, I created a Canvas-prefab since all the UI-elements need to be identical in every level.

For every scene I dragged the Canvas-prefab from the Projects-Tab to the scenes hierachy and added also an EventSystem, respectively. The references through the scripts are working (e.g. text-elements are updating) but when I want to click on a button or slider it is not possible although its components interactable booleans are set to true and the onClick functions are connected.

However, there is no physical object infront of the canvas, since I have it set on "ScreenSpace - Overlay" and blocking raycasts is set as default to none.

Obviously, only the original Canvas on the first level scene is fully working (for some reason when I open the scene again it is not marked with blue text anymore).

Comment
Add comment · Show 1
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 IliaFamous · Aug 01, 2017 at 01:51 PM 0
Share

Please check, whether you have an Event system in the scene or not. Was it for me.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Baxter900 · Oct 11, 2015 at 05:27 AM

Hmm, so there's a couple things it might be, but first of all I'm going to recommend something different. If I'm understanding your needs correctly, you need the identical UI in all the scenes? Right? Well we can actually keep using the UI in all the scenes. Just make a script and call it "DontDestroyOnLoad", attach it to your canvas, then in the Awake method put: DontDestroyOnLoad (transform.gameObject); This will make it so that when you switch scenes, your UI stays around. To get rid of your UI, just call the Destroy() method on it.

If for some reason you can't do this, here are a couple of reasons that things might not be interacting right.

The first is if Unity thinks there's something in front of your canvas, even if it's not visible, that can cause it to block the mouse raycasts and say that there's another button or object in front of it. Try playing around with the elements in front of it and checking whether they are interactable or block raycasts.

I know I like to sort and control my UI with Canvas groups, which offer you a master control for the alpha, interactability, and raycast blocking of an object and all it's children. So you can try using that to see if it can help.

Next check that you're buttons still have the links to the correct functions. I've found that a lot of times, prefabs with button's in them lose the button's script link, causing the buttons to apparently do nothing. This wouldn't affect the slider though, suggesting the first one.

The next thing to check is the physical layering of stuff, there are a couple things that will cause things to not be interactable unpredictably. If you're using the Screen Space - Camera mode (or the World Space with it parented to the camera, don't do that by the way...), then if you're UI is behind the camera due to the plane distance, it won't work. More common, if the back side of your UI is facing the camera, you won't be able to click on anything by default. Next make sure Blocking Objects is set to None in the Graphic Raycaster, if it's not, something in the physical world might be blocking it.

Those are all I can think of off the top of my head. But I'll add more if I can think of them. Good luck in getting this fixed, and if you provide more data on your UI setup, I might be able to help more.

Comment
Add comment · Show 2 · 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 Noxury · Oct 11, 2015 at 05:41 PM 0
Share

@Baxter900: Many thanks for your lines of thoughts! I think I will use the DontDestroyOnLoad() function, because I had everything else before like you described it.

avatar image Baxter900 Noxury · Oct 11, 2015 at 05:47 PM 0
Share

Alright, sorry that I couldn't help more, without more information though, I don't know what could be causing the problem, since I haven't run into it before. At least you got the idea to use DontDestroyOnLoad though, which might save you from some runtime overhead.

avatar image
0

Answer by deanb · Jul 20, 2016 at 02:27 PM

wrapping the prefab in an empty gameobject on the root at 0,0,0 fixed this for me.

Comment
Add comment · 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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

42 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

Related Questions

Highlight button via script at runtime 3 Answers

Eventsystem requires window focus? 0 Answers

Screen Space - Camera Bug (Buttons does not work) on Unity 2017 0 Answers

How to stop EventSystem from triggering on two different displays/canvases? 0 Answers

Detect if player wants to pause or to jump 3 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges