Whether from a menu item, or an Inspector view, there are times when we want to create a new GameObject in the scene from an Editor Extension. In this recipe, we'll create a new GameObject and set its position and color randomly:
![](https://static.packt-cdn.com/products/9781788471909/graphics/assets/8c5ba467-2b3e-4745-bb68-6d273af200dd.png)
Whether from a menu item, or an Inspector view, there are times when we want to create a new GameObject in the scene from an Editor Extension. In this recipe, we'll create a new GameObject and set its position and color randomly:
To create an object and change its value follow these steps:
using UnityEditor;
using UnityEngine;
public class ObjectManager : EditorWindow
{
[MenuItem("GameObject/MyObjectManager/Create New Empty Game Object")]
static void CreateCustomEmptyGameObject...