How to make unity to continue focusing a the GameObject after it instantiates child element.
Hi I did a Unity Editor script called LevelManager. It instantiates and places new level objects to the scene where you click on the screen. The problem is, after it instantiates a GameObject and place it as a child of the LevelManager , Unity loses focusing of that game object (LevelManager). Thus, I have to re-select the LevelManager object on the scene to continue creating new level objects. Why Unity loses focusing? It focus to the game object I instantiated, not the parent one (LevelManager).
If I'm not wrong and If I remember right, there was some attribute to fix this problem. Does anybod know this, how can I fix it?
Answer by hazarartuner · Jun 05, 2017 at 11:07 PM
I found the solution :)
In the Editor script place this code into the OnSceneGUI() method like this:
public void OnSceneGUI()
{
// some code
// some code
// some code
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
}
Your answer
Follow this Question
Related Questions
Assign variables on Instantiation? 0 Answers
Add Component with Script Data 1 Answer
How to change the Bool for only a single prefab GameObject creating with Instantiate? 2 Answers
How could i save a variable called by multiple objects using the same script? 1 Answer
Bullet not inheriting speed of player. 0 Answers