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 Andr · May 16, 2012 at 04:13 PM · guieditorcustom inspector

How to make a Custom inspector?

The simple question is how to make a custom inspector.

The long(er) version is I have difficulty understanding the principles behind it. I need the inspector to get data from a script based on an input field from the same inspector. The altered information should automatically be save when i hit enter. (I figure i just can use GUI.changed)

The Image is the GUI only and none of it have any functions to it yet.

Can anyone help me?

How do I in JavaScript:

  • Get Variables from another script (in another folder)

  • Save data to that script again so it persist

  • make a new script from the inspector just by hitting a button. (Maybe a prefab of the script, then copy it and edit the new one?)

alt text

Skærmbillede 2012-05-16 kl. 17.08.56.png (26.8 kB)
Comment
Add comment · Show 2
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 hesa2020 · May 16, 2012 at 07:33 PM 0
Share

In c# to acces a variable in another script you do : NA$$anonymous$$EOFTHESCRIPT.VARIABLE

avatar image Andr · May 16, 2012 at 07:42 PM 0
Share

Sorry didnt mention it should be in JS. Is it worth learning C#, it looks like most things is fairly easy in C#

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Tasarran · May 16, 2012 at 08:18 PM

I can help with the first two parts...

To access and save variable data from another script, you should have that script attached to something in your scene. Just one copy of it.

Use this line:

 var otherScriptObject : GameObject;

Drag that object into that variable in the inspector. You can also find it using GameObject.Find(), but this is the easiest way.

Then find that script from your first one with this line:

 var otherScript = otherScriptObject.GetComponent("nameOfOtherScript");

Then you can refer to variables (and functions) in that script like this:

 otherScript.someVariable = 3.14;
 otherScript.someFunction();
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 DaveA · May 17, 2012 at 02:47 AM

If I understand part 3, you want to make a new script onto an game object? That's AddComponent()

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

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

6 People are following this question.

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

Related Questions

Custom Inspector not working with inheritance. 2 Answers

Trigger an event from editor script? 0 Answers

Custom Material Editor 1 Answer

custom inspector label width? 4 Answers

How To Open GUI Editor? 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