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 DaiMangouDev · Jan 26, 2015 at 01:42 AM · c#editorinspector

Can Editor Windows function like the inspector ?

Hi. In the inspector window, we can have multiple objects with rigidbodies with different mass values. upon selecting one of these objects the mass value asscociated with the selected object is displayed in rigidbody in the inspector. At runtime , each object reads from its mass value.

Can Editor Windows be created to execute functions at runtime in the same way and for each object that I select , the editor windows will display only the values associated with the selected object ?

If so then How do I go about implementing it. I would be grateful for any examples.

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
1
Best Answer

Answer by immersiveGamer · Jan 26, 2015 at 03:14 AM

I think you have the Editor Windows a bit confused with components. Each game object has a component on it. When you select a game object it shows each of the components on the game object, like the rigidbody.

Editor Windows are not run at runtime if you try to use any actual Editor Window. What you want is to create a script. When you create a script in Unity it will act like a component. This way you can drag the script onto your game object and it will be like a component. Any public variables in the script will shown in the inspector and you can change them for each object, just like the mass value on the rigidbody.

Here is an example script:

 using UnityEngine;
 using System.Collections;
 
 public class ScaleScript : MonoBehaviour {
 
     //since this is public it will show in the inspector. 
     //even though it is set to 1 here if we change it in the
     //inspector it will stay as the value we changed it to.
     public float scale = 1.0f;
 
     // Use this for initialization
     void Start () {
         //multiplies the current scale by the SCALE variable. 
         gameObject.transform.localScale = gameObject.transform.localScale * scale;
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 }
 

Here is what it looks like in the inspector. I've put it on each sphere and set the scale to a different value. When we run the scene it changes each one to the value we had set it to. This is like the mass we would set for the rigidbody.

alt text

Now there are Editors that you can make to make the script look nicer and fancier and editor windows that are not attached to any object, but for either to work with a game object you need to have a script coded and put on it first like above. I do apologize if this is not what you are looking for. You question was a bit hard to read and understand. Please leave a comment if you need clarification or a different answer.


screenshot-2015-01-25-210642.png (66.0 kB)
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 DaiMangouDev · Jan 26, 2015 at 03:41 AM 0
Share

this really cleared up my misunderstanding . thank you very much . so its only a matter of exposing the variables in script so that the editor window can access them.

avatar image
1

Answer by cdrandin · Jan 26, 2015 at 02:51 AM

Can Editor Windows be created to execute functions at runtime in the same way and for each object that I select , the editor windows will display only the values associated with the selected object ?

Yes it can be.

Here are some references.

Selection

Editor.Window

Editor

EditorGUILayout

Format the window to your liking. If you want to execute some arbitrary code. Use the selector method. Determine what type you are dealing with executes its respective 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 DaiMangouDev · Jan 26, 2015 at 03:42 AM 0
Share

thank you very much, this will help me greatly.

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

20 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

Related Questions

ReImport in c# of GameObjects only for Scene Objects, not assets? 1 Answer

TexturePropertySingleLine in Editor class 0 Answers

Custom Inspector - How to add functionality? 1 Answer

Editor Script, Index Out of Range Exception after Play 1 Answer

Gizmos.DrawLine is dissapearing after returning to editor after Playing the scene 0 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