Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Ambrose998800 · Oct 06, 2016 at 06:47 AM · inspectorvalues

Transfer inspector value into script variable (C#)

Hi there.

For script optimisation, I'm looking for a way to transfer values from an object to the an assigned script.

Usage: My script contains two positions (Vector3), a "first-position" and a "moved-position". Now I want to put an objects position into the first Vector3, then move it inside the editor, and then assign the new position to the second Vector3, without typing in every single transform value by hand/copy+paste.

Is there a possibility to assign the values to a variable by a button in the inspector?

Greetings

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 chillersanim · Oct 06, 2016 at 07:42 AM

If you just wan a button that does that, you can create an InspectorEditor for your script and use the GUILayout.Button() to create a button.
https://docs.unity3d.com/ScriptReference/GUILayout.Button.html

Otherwise, if you just need a reference, you should go with aditya's answer.

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 Ambrose998800 · Oct 08, 2016 at 06:37 AM 0
Share

This led the way! Thx.

For anyone else: ADDING BUTTONS TO A CUSTO$$anonymous$$ INSPECTOR: https://unity3d.com/learn/tutorials/topics/interface-essentials/adding-buttons-custom-inspector

avatar image
1

Answer by aditya · Oct 06, 2016 at 06:51 AM

 public Transform yourObject;
 
 private Vector3 firstPosition;
 
 void Start(){
     firstPosition = yourObject.position;
 }

Drag-Drop your object in yourObject field through inspector and fetch its position in your Vector3

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 Ambrose998800 · Oct 06, 2016 at 08:22 AM 0
Share

That doesn't help; I can't go over the Start or Awake or any runtime function, as long as superposition isn't working in unity.

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

58 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

Related Questions

Link a value to another value in the Inspector 1 Answer

Arrays and the inspector 1 Answer

Unexpected values at the inspector when initializing member values from built-in arrays 0 Answers

Inspector won't update with new variables.,Variables don't seem to update on inspector 0 Answers

Are inspector values supposed to override [HideInInspector] code? 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