Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Joey B · Jan 24, 2015 at 03:24 PM · componentguitextcustom

Is it possible to create a custom Game Component?

I currently just started using Unity 4.6. I just finished the 2nd of the 3 main project tutorials in an effort to get comfortable using Unity. In the tutorial videos, they make reference to a GUIText Game Object that can be added from the Hierarchy; however it doesn't look like this is still available in the more recent versions. I got around this by creating a Blank Game Component, and then adding the GUIText component from Rendering-> GUIText; however this adds an extra step. Is there a way to save this "base" game component as a custom? Any help is appreciated. Thanks,

Joey

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by tanoshimi · Jan 24, 2015 at 03:25 PM

Every script you write and attach to a gameobject is a custom component - that's what they are ;)

But don't use GUItext - it's deprecated and has been replaced by UI introduced in Unity 4.6 (there's tutorials in the Learn section of this site)

Comment
Add comment · Show 4 · 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 Joey B · Jan 24, 2015 at 04:28 PM 0
Share

I did see the Canvas/UI Functionality - and will definitely check out the Learn section to find out more. For the purposes of the Tutorial I was trying to follow along and noticed the difference. Thanks for the info!

avatar image Joey B · Jan 24, 2015 at 04:32 PM 0
Share

Either way - I guess my question still stands. Is it possible to create a custom component that can be added from the Hierarchy/Create menu? One that has preset values that I have set previously. Would I use a Prefab for this?

avatar image tanoshimi · Jan 24, 2015 at 04:42 PM 0
Share

You just add the AddComponent$$anonymous$$enu attribute to the top of your class - http://docs.unity3d.com/ScriptReference/AddComponent$$anonymous$$enu.html

avatar image Joey B · Jan 24, 2015 at 05:05 PM 0
Share

This will work perfectly along with Owen's suggestion below. Thanks again.

avatar image
0

Answer by Owen-Reynolds · Jan 24, 2015 at 04:52 PM

As you note, the cheap way is to make a prefab, set up the way you like. For example, the Legacy particle system also no longer has an entry under Create, and also needs to be assembled from (3!) components. Easy to just drag-create a prefab after the first time you make one.

The fancy way to do exactly what you want is an Editor Script. They can run code in the Editor (create Components, attach to gameObjects, ...) put tools in the Inspector, and can(?) be set to run from dropDowns.

Comment
Add comment · Show 1 · 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 Joey B · Jan 24, 2015 at 05:05 PM 0
Share

Excellent, thanks so much.

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.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Custom inspector, show string instead of component type 0 Answers

Gui text component on an object not showing up? 0 Answers

2D Animation does not start 1 Answer

Enable ChildObject of Player with OnTriggerEnter? Or a whole different method? 0 Answers

Problem with getting component, help please? ^^' 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges