Quantcast
Channel: UGUI & TextMesh Pro
Viewing all articles
Browse latest Browse all 23263

How do you get the parent canvas?

$
0
0
Is there a simple way to get the parent canvas of a UI element?

Because for functions like:


Code (CSharp):
  1.         RectTransformUtility.ScreenPointToLocalPointInRectangle(colorpad.rectTransform,Input.mousePosition,Camera.main,out localPoint);
  2.  

you need to know whether the canvas is in Overlay mode or Camera mode. In order to either put Camera.main or null in the field.

Or am I missing something? I don't want to put a public variable Canvas because I am making a prefab that...

How do you get the parent canvas?

Viewing all articles
Browse latest Browse all 23263

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>