Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 viv5552 · Jan 08, 2021 at 09:37 AM · unityeditorbeginnernoobnewbienew user

Can you assign a simple variable directly in Inspector without writing a script?

When i only need to assign a single integer or float i'm writing a script that declares a public float/int/etc and then filling it in the Inspector. Would be nice to just add a float/int/string as a Unity built in component like all that other stuff in the Inspector.

Comment
Add comment · Show 3
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 Hellium · Jan 08, 2021 at 10:02 AM 1
Share

When i only need to assign a single integer or float

Assigning to what?


If you want to associate data to a gameObject, either you attach a script to it with the data you need, or you create a dictionary gameObject → data in the script needing the information.

avatar image viv5552 Hellium · Jan 08, 2021 at 01:02 PM 0
Share

Yeah that's what i'm talking about. But to me as a noob in program$$anonymous$$g it seems kinda weird that you need to create a whole separate script just for adding a single number to gameobject. I mean there are all sorts of complicated things (Physics stuff, Animations, Particle Systems etc.) which can be assigned in one click to gameobject via editor gui and compared to this manually writing a primitime single line script for assigning a float or int looks like unnecessary overcomplication.

avatar image Hellium viv5552 · Jan 08, 2021 at 01:07 PM 0
Share

Behind the hood, Physics, Animation, ... components are scripts.


Having a dedicated (simple) component to associate data to a gameObject is possible. However, I$$anonymous$$HO, it's a symptom of bad architecture. Components are meant to give behaviour to a gameObject, i.e, make a gameObject do things.


If you need to associate data to a gameObject, I would not go with a "data container component". The solution heavily depends on what's must be done and the current architecture.

3 Replies

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

Answer by MomkeyDev · Jan 08, 2021 at 02:44 PM

If you mean something like adding a component. Nah you can't.

Comment
Add comment · Show 3 · 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 viv5552 · Jan 10, 2021 at 06:40 AM 0
Share

That's sad.

avatar image MomkeyDev · 6 days ago 0
Share

Actually sorry, you might actually can ? If you mean something like adding a simple variable that can be referenced later. You can make your own script to do that. Just make sure you add a way to know which variable is which (Like making some kind of search function) Still really not recommending it but it really depend on what you're trying to do.

sorry to bump old thread, but i feel guilty to say misinformation

avatar image Bunny83 MomkeyDev · 6 days ago 0
Share

Well, to be fair, his question ended with

without writing a script?

avatar image
1

Answer by Stonemass · Jan 08, 2021 at 01:18 PM

yep...like others things but....not. i really hate the boolean behavior.

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

Answer by logicandchaos · Jan 10, 2021 at 12:54 PM

Yes and no, you still have to make a script.. but if you make a script that inherits from scriptableObject and stores just one variable, then you can make variables in your project folders, it's a great way to connect all your code.

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 viv5552 · Jan 10, 2021 at 01:01 PM 0
Share

I'm very new to both program$$anonymous$$g and unity so i don't fully understand what you mean. Can you explain it on a noob level?

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

122 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

i can not find a good tutorial for Bolt and unity Mars 0 Answers

a box expands and shrinks after key pressed with a sound? 2 Answers

Can't point Main Camera to Plane 0 Answers

Issues with Translations and OnTriggerExit 0 Answers

How do I keep the camera from rolling? 1 Answer


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