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 /
This question was closed Mar 30, 2015 at 06:44 PM by jpthek9 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by jpthek9 · Mar 30, 2015 at 05:07 AM · inspectorserializationscriptableobjectmonoscript

How do I save scripts as variables in the inspector?

For my moddable ability system, I've created a number of scripts that I wish to attach to game characters easily that represent abilities. Is it possible to have a field in the inspector where I can drag and drop scripts into? I've tried using MonoScript but it becomes problematic when I try to build the game.

The context of what I'm trying to do is an RTS game where there can be a variety of units selected with different abilities. Each ability has an input ID but the ability that responds to 'Q' on one unit might be different from the ability that responds to 'Q' on another unit. I want to customize the abilities so that calling a command on a group of units calls their abilities assigned to that command's ID (aka input ID). I want to make ability customization easy and organized which is why I want to take advantage of the inspector.

Given the context, I'd like a reasonably efficient method of organizing abilities in a developer friendly way. Having all the abilities inherit from MonoBehaviour and getting them with GetComponent would be very demanding I think.

Comment
Add comment · Show 5
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 fafase · Mar 30, 2015 at 05:59 AM 1
Share

I might be misunderstanding but making a reference variable public then it shows in the inspector and you can drag it there. Use SerializeField if you want to keep it private. Am I missing something?

avatar image sumeeton · Mar 30, 2015 at 08:46 AM 0
Share

Why would you want to drag and drop scripts into a script component to access it when you can access it directly?

avatar image jpthek9 · Mar 30, 2015 at 09:44 AM 0
Share

"For my moddable ability system, I've created a number of scripts that I wish to attach to game characters easily that represent abilities." That pretty much sums it up. Note that I have to create instances of each ability class. I've added several more details to the OP that might give the question some context.

@fafase I've tried having an array of the abstract class abilities are derived from but this class doesn't show up in the inspector unfortunately.

avatar image fafase · Mar 30, 2015 at 10:46 AM 1
Share
   Having all the abilities inherit from $$anonymous$$onoBehaviour and getting them with GetComponent would be very demanding I think.

Well, kinda wrong. The point of the $$anonymous$$onoBehaviour and prefab system is that it makes development easier. You can go back in time by using a txt/json/xml file that you parse to fill up data on a non $$anonymous$$ono-Behaviour script but that would be more hassle than simply adding scripts, filling values, making them prefabs and instantiate when needed.

avatar image jpthek9 · Mar 30, 2015 at 06:43 PM 0
Share

I'll just create a dictionary of classes and use strings to access them. Headache: Disarmed. The main reason why I can't use GetComponent is because there might be 30 units spawning at one time (spawn waves) and each unit has up to 8 abilities so that's up to 240 GetComponents in 1 frame.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

21 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

Related Questions

[Solved]Why doesn't my ScriptableObject based asset save using a custom inspector ? 1 Answer

Difference between assigning a value in inspector and with a custom editor script 1 Answer

How should I serialize data that is also editable in the Inspector? 2 Answers

Why doesn't my ScriptableObject save using a custom EditorWindow? 3 Answers

Creating ScriptableObject Asset "Failed to write meta file" 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