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
3
Question by v0kb0l0k · Jan 26, 2014 at 03:20 PM · vector3inspectorpivotpublic

Inspector public with movable pivot in editor window.

Can I create something like Vector3 public in inspector that has movable pivot in editor? Whithout attaching any game object.

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 Max-Pixel · Apr 03, 2014 at 11:41 PM 0
Share

I concur! It would be amazingly useful to enable a gizmo for any public Vector3 or Vector2.

avatar image Scribe · Apr 05, 2014 at 02:44 PM 0
Share

If your question has been answered I'd appreciate if you marked it as such, or please explain if the code posted isn't working for you and I can try to help!

Scribe

1 Reply

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

Answer by Scribe · Apr 04, 2014 at 03:43 AM

Well this took me a little while to figure out but this seems to work, just copy it into a file: V3visulization.cs and have it somewhere in your assets folder (doesn't need to be in an 'Editor' folder), the rest should work for Vector3's (I haven't bothered with Vector2's, they shouldn't be hard to add yourself with this start):

 using UnityEditor;
 using System.Reflection;
 using UnityEngine;
 
 [InitializeOnLoad]
 class V3visulization{
     static V3visulization(){
         SceneView.onSceneGUIDelegate += OnSceneGUI;
     }
     
     static void OnSceneGUI(SceneView scnView){
         GameObject selObj;
         Vector3 v3;
         MonoBehaviour[] scripts;
         
         selObj = Selection.activeGameObject;
         if(selObj != null){
             scripts = selObj.GetComponents<MonoBehaviour>();
             for(int i = 0; i < scripts.Length; i++){
                 MonoBehaviour data = scripts[i];
                 FieldInfo[] fields = data.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
                 for(int j = 0; j < fields.Length; j++){
                     if(fields[j].GetValue(scripts[i]).GetType() == typeof(Vector3)){
                         v3 = (Vector3)fields[j].GetValue(scripts[i]);
                         v3 = Handles.PositionHandle(v3, Quaternion.identity);
                         fields[j].SetValue(scripts[i], v3);
                     }
                 }
             }
         }
     }
 }

Hope that helps you!

Scribe

Comment
Add comment · Show 2 · 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 flamy · Apr 04, 2014 at 03:51 AM 0
Share

+1, nice work.

avatar image v0kb0l0k · May 29, 2014 at 03:24 PM 0
Share

Great, thank you!:) but I need real transforms like gameobject transform in inspector with moving and rotation gismos

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

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

How is the rotation of a Transform converted into a Vector3 in the inspector ? 2 Answers

Using [SerializeField] vs public 2 Answers

Cannot assign Public GameObject variable in Inspector... 2 Answers

Set number of public objects through the inspector 1 Answer

Public "char" parameter not showing on inspector? 2 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