Classy Games Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

☰ Open Navigation

Latest topics
Management Quota Admission Open 2018 -19 Fri May 25, 2018 7:44 amrajkapurkm
Enter as Student...Exit as Professional!!Tue Feb 13, 2018 12:39 pmShizuka
Hello!!Tue Feb 13, 2018 12:35 pmShizuka
Digital marketing serviceTue Jan 23, 2018 10:24 amwwwww
Digital marketing services in Bangalore IndiaTue Jan 23, 2018 10:23 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
Intro to 3D positional sound in Unreal EngineFri Nov 03, 2017 6:44 pmmoradenayet
Game Off - 5th annual GitHub game jamWed Nov 01, 2017 2:54 pmMatita
Ludum Dare 40th RecruitmentTue Oct 31, 2017 11:02 pmMrJamieMcC
What is one of your favorite art styles?Tue Oct 31, 2017 8:24 pmMatita
Tips on how to approveTue Oct 31, 2017 7:43 pmMatita

Go down
MrJamieMcC
MrJamieMcC
Administrator
Posts : 78
Join date : 2017-09-25
http://jamiemcclenaghan.co.uk

Require Component Empty Require Component

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
Back to top
Permissions in this forum:
You cannot reply to topics in this forum