- Home /
Question by
Gilles_aerts · Mar 02, 2019 at 09:06 AM ·
uicanvasgetcomponentpublic variableprivate
assigning my Canvas variable to the only Canvas I have in game
hi, I have A canvas named Canvas in my scene and I want to assign it to my Canvas variable via code. I don't want to make it a public variable and drag it. any idee's ? I tried GetComponent but without succes . ( the script is not attached to the canvas itself btw)
Comment
Best Answer
Answer by Nivbot · Mar 02, 2019 at 09:32 AM
Canvas canvasVariable = GameObject.Find(“name”).GetComponent<Canvas>();
Your answer
Follow this Question
Related Questions
Multiple Text of canvas with One script ?? 1 Answer
Most efficient way to check if a component is null for a canvas or UI? 1 Answer
Canvas appearing over my cursor doesn'tr trigger OnPointerExit ! 0 Answers
Menu not getting Keyboard Input 0 Answers
Lags when clicking so many times,Have problem when clicking so many times 1 Answer