Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Showing a scaling from Custom Editor's OnEnable in Sceneview automatically

Discussion in 'Scripting' started by bawenang, Jul 15, 2014.

  1. bawenang

    bawenang

    Joined:
    Aug 18, 2012
    Posts:
    119
    Hi, I've got this in my project:

    Code (CSharp):
    1. [CustomEditor (typeof(GridGround))]
    2. public class GridGroundEditor : Editor {
    3.  
    4.     GridGround ground;
    5.  
    6.     bool needRefresh = true;
    7.  
    8.     public void OnEnable()
    9.     {
    10.         //Settings
    11.         ground = (GridGround)target;
    12.         SceneView.onSceneGUIDelegate += this.GridGroundUpdate;
    13.            
    14.         ground.transform.localScale = new Vector3(GridOptions.instance.gridWidth, 2.0f, GridOptions.instance.gridHeight);
    15.  
    16.     }
    17. ...
    18. }
    Now as you can see in the OnEnable, I'm trying to scale the GridGround object upon creation. It worked actually, but the scene view still is still showing me the un-scaled one from the prefab. Even though, when I select the GridGround gameobject manually in the scene view, it will change it's appearance to the scaled one. It's only a minor issue actually but still it is annoying. Can you guys help me? Thanks.

    BTW, I've been trying to search for the documentations for SceneView to no avail. Is it not documented intentionally?

    Thanks in advance.
     
  2. bawenang

    bawenang

    Joined:
    Aug 18, 2012
    Posts:
    119
    Nothing yet? *bump*
     
  3. Medding3000

    Medding3000

    Joined:
    Dec 11, 2013
    Posts:
    45
  4. bawenang

    bawenang

    Joined:
    Aug 18, 2012
    Posts:
    119
    Thanks for the reply. It worked most of the time but not always. Good enough for now. :)