- Home /
Inspector top not working properly
When I'm using a custom editor script my Inspector looks like this:

I can still use/acces things like the layers tags ect. but can't enable/disable GameObjects. The script that I use allows me to snap gameobjects in de editor, it works fine and gives me no errors but turns the top part all weird. Am I missing something important in my custom editor script?
This is the script I'm using:
 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 
 [CustomEditor(typeof(GameObject))]
 public class SnappingEditor: Editor
 {
 
     public float snapValue = 16;
     public float depth = 0; 
 
     public bool SnapMode = true;
     
     void OnSceneGUI()
     {
         Handles.Label(new Vector3(0, 10, 0), "SnapMode: " + SnapMode);
 
         Event e = Event.current;
 
         switch (e.type)
         {
             case EventType.keyDown:
                 {
                     if(Event.current.keyCode == (KeyCode.Alpha1))
                     {
                         if(SnapMode)
                         {
                             Debug.Log("SNAP MODE: OFF");
                             SnapMode = false;
                         }
                         else
                         {
                             Debug.Log("SNAP MODE: ON");
                             SnapMode = true;
                         }
                     }
                     break;
                 }
         }
 
         if(Selection.activeGameObject != null && SnapMode && Selection.activeGameObject.layer == LayerMask.NameToLayer("FloorTiles"))
         {
             float snapInverse = 1/snapValue;
             float x, y, z;
 
             x = Mathf.Round(Selection.activeGameObject.transform.position.x * snapInverse)/snapInverse;
             y = Mathf.Round(Selection.activeGameObject.transform.position.y * snapInverse)/snapInverse;   
             z = Mathf.Round(Selection.activeGameObject.transform.position.z * snapInverse)/snapInverse;
             
             Selection.activeGameObject.transform.position = new Vector3(x, y, z);
         }
         else
         {
 
         }
     }
 }
Your answer
 
 
             Follow this Question
Related Questions
How do I change inspector values of other game objects using a custom Editor Window 0 Answers
How do I change inspector values of other game objects using a custom Editor Window 0 Answers
Inspector: custom property with custom type use default editor 3 Answers
How do I change inspector values of other game objects using a custom Editor Window 0 Answers
Custom Inspectors for generics and tweaking default inspectors 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                