Unity 2021.3.8f1:
Pasteboard - Uploaded Image
I have a script “Assets\Editor\SphereLoadEditor.cs”
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(SphereLoad))]
public class SphereLoadEditor : Editor
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnSceneGUI()
{
SphereLoad t = (SphereLoad)target;
GUIStyle style = new GUIStyle();
style.fontSize = 1;
style.normal.textColor = Color.red;
Vector3 tpos = t.transform.position;
tpos.x = tpos.x + 2.0f;
tpos.y = tpos.y + 2.0f;
tpos.z = tpos.z + 2.0f;
Handles.Label(tpos, "Hello World!", style);
}
}
I have another script “Assets\SphereLoad.cs”
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class SphereLoad : MonoBehaviour
{
GameObject mGameObject;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
There are no errors or warnings present in the Unity console error when I run the scene. I do not see any labels showing up in the scene at all. For some reason I am not able to get a breakpoint to trigger in the editor script or get the autocomplete working in Visual Studio however the script does seem to be processed by Unity as I had to fix a few script issues in order to get the scene to start up. So far I would like to check the status of the position coming into the editor script I also tried to manually enter a vector position for a Handles.Label such as:
Vector3 tv = new Vector3(2.0f, 2.0f, 2.0f);
Handles.Label(tv, "Hello World!", style);
That also did not seem to draw a label in scene view. Is there a way to get the scene view labels to start to show up in scene view?