#Creating SO & GO in editor

1 messages · Page 1 of 1 (latest)

dim dove
#
private static void CreateWorldTilemap(string strID, Vector2Int vTilemapSize)
    {

        GameObject goTilemapWorldCurrent = new GameObject(strID);

        ScriptableObject soTilemapWorldCurrent = new soTilemap(strID, vTilemapSize.x, vTilemapSize.y);

        Component ScriptAdded = goTilemapWorldCurrent.AddComponent(typeof(MonoScript));

    }

    private void OnGUI()
    {
        EditorGUILayout.PrefixLabel("Editor ID: ");
        string strID = EditorGUILayout.TextField("");

        Vector2Int vTilemapSize = EditorGUILayout.Vector2IntField("Tilemap Size", new Vector2Int (1, 1));

        if (GUI.Button(new Rect(60, 120, 200, 80), "Create World Tilemap"))
        {
            Debug.Log("Clicked!");

            CreateWorldTilemap(strID, vTilemapSize);
        }

    }```
This is the wee snippet of code I have so far
#

Component ScriptAdded = goTilemapWorldCurrent.AddComponent(typeof(MonoScript)); Passing MonoScript here throws an error. It's not a component type.

#

What do?