Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Snazsh · Mar 02, 2021 at 07:48 PM · editorsceneviewhandlesonscenegui

Keep multiple custom handles visible in the Scene view

Hi, I have created a custom Editor to create a path system with waypoint with custom Handles which works fine.

My problem is that my custom handles are hidden when I am not selecting my gameobject which is a normal behavior but I didn't managed to make it work properly in my case.

This is what I tried to do :

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 
 [CustomEditor(typeof(PathCreator))]
 public class PathEditor : Editor
 {
     public override void OnInspectorGUI()
     {
         // Show some button in my Inspector window
     }
 
     private void OnSceneGUI(SceneView sv)
     {
         Input();
         Draw();
     }
 
     void Input()
     {
         // Adding or removing some waypoint
     }
 
     void Draw()
     {
         // Add the custom handles
     }
 
     private void OnEnable()
     {
         SceneView.duringSceneGui += OnSceneGUI;
 
        // Some code to create my path
     }
 
     private void OnDisable()
     {
         SceneView.duringSceneGui -= OnSceneGUI;
     }
 
     private void OnDestroy()
     {
         SceneView.duringSceneGui -= OnSceneGUI;
     }
 }

The two method OnDisable and OnDestroy are being called every time I am unselecting my game object while I thought only OnDisable would've been called.

If I do not add the SceneView.duringSceneGui -= OnSceneGUI; in those two method above, the handles stays and it's kinda fine but I have a couple of issue :

  • The first one is that I have a "Reset" button in my custom Editor that reset the position of the path like so :

       public override void OnInspectorGUI()
         {
             base.OnInspectorGUI();
             if (GUILayout.Button("Reset"))
             {
                 creator.CreatePath();
                 path = creator.path;
                 checkpoints = creator.checkpoints;
                 for (int i = 0; i < path.NumPoints; i++)
                 {
                     checkpoints.AddCheckpoint(Vector3.zero);
                 }
                 selectedPoint = -1;
                 SceneView.RepaintAll();
             }
         }
    
    

I don't think you need to get all the code here but I do a SceneView.RepaintAll(); once my path is being reset and this works when I am not using SceneView.duringSceneGui -= OnSceneGUI;, it doesn't remove the older path and add a new (the reset) one. What should I do in that case ?

  • The second issue is that, I will need to show multiple path at the same time in my Scene window. How does that works with adding OnSceneGUI to SceneView.duringSceneGui ?

Thanks for the help

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

0 Replies

· Add your reply
  • Sort: 

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

152 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 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 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

Handles.ScaleValueHandle and values < 0 0 Answers

Select object by selecting gizmo or handle? 1 Answer

PositionHandle causing problems 0 Answers

Using Handles.DrawAAPolyLine 1 Answer

Handles.matrix seems strange? 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