Selection.activeGameObject
Scripting > Editor Classes > Selection
Selection.activeGameObject

static var activeGameObject : GameObject

Description

Returns the active game object. (The one shown in the inspector)

It will also return game objects that might be prefabs or non-modifyable objects.