I’m attempting to get into editor scripting but i haven’t had any luck for the life of me. currently what i’m trying to accomplish is to have the console print out the name of the game object that has just been selected in the hierarchy or scene view. From what I’ve researched i assume I’ll need the following snippet of code somewhere:
print (Selection.activeGameObject.name);
but i cant seem to figure out how to get the code running up to that point. This code i made seems to make sense to me (and i’ve placed the script in an “Editor” folder in my project view) but it doesn’t execute.
using UnityEngine;
using System.Collections;
using UnityEditor;
public class PrintObjectName : MonoBehaviour {
void OnSelectionChange(){
print (Selection.activeGameObject.name);
}
}
If anybody could at least get me going in the right direction that’d be a tremendous help!