☰ Open Navigation

Latest topics
Hello!!Tue Feb 13, 2018 12:35 pmShizuka
Digital marketing serviceTue Jan 23, 2018 10:24 amwwwww
Classy Games Project IdeasSun Dec 17, 2017 3:16 pmMatita
Awesome Music VideosSun Nov 26, 2017 8:43 pmApril
Whatever WarsMon Nov 20, 2017 9:57 amMrJamieMcC
Welcome VeteransWed Nov 08, 2017 8:29 amMatita
GroupsTue Nov 07, 2017 4:29 pmMrJamieMcC
Low Poly TankMon Nov 06, 2017 8:16 pmMrJamieMcC
What mic do i need?Mon Nov 06, 2017 8:10 pmMrJamieMcC
Moonlit Development GamesSat Nov 04, 2017 12:11 pmDylan
Mentioning UsersSat Nov 04, 2017 11:42 amMrJamieMcC
Ludum Dare 40th RecruitmentTue Oct 31, 2017 11:02 pmMrJamieMcC
Tips on how to approveTue Oct 31, 2017 7:43 pmMatita

Go down
Posts : 78
Join date : 2017-09-25
View user profilehttp://jamiemcclenaghan.co.uk

Require Component Empty Require Component

on Tue Oct 03, 2017 6:40 pm
Sometimes in script you require the object to have a certain component. This may be a rigidbody, text, box collider. Anything at all.
Sometimes when you try and use a component which isnt there a lot of errors/bugs and crashes can occur, which we all know is very frustrating.
Using the “RequireComponent” means you cant delete the component while this script is attached. Its awesome!
For example; Say we are manipulating the Text element of the UI.
At the top of the script. After the using and before the class we type
“ [RequireComponent(typeof(Text))] “
Like this.
Require Component 5c6ddb85e87a567af5d4a056ea498a85

This will now mean we cant remove the component in the inspector.

Like this.
Require Component Giphy


Require Component LbMpndQ
Back to top
Permissions in this forum:
You cannot reply to topics in this forum