Ejemplo n.º 1
0
    void OnEnable()
    {
        EditorApplication.playModeStateChanged += OnPlayModeChanged;
        itemDatabase = AssetDatabase.LoadAssetAtPath <ItemDatabaseScriptableObject>("Assets/Scripts/Database/ItemDatabase.asset");
        if (itemDatabase == null)
        {
            itemDatabase       = ScriptableObject.CreateInstance <ItemDatabaseScriptableObject>();
            itemDatabase.items = new List <ItemData>();
            ItemData item = new ItemData
            {
                itemID    = (ushort)itemDatabase.items.Count,
                itemName  = "NewItem",
                stackSize = 64,
                //Add more default stuff here
            };
            itemDatabase.items.Add(item);
            AssetDatabase.CreateAsset(itemDatabase, "Assets/Scripts/Database/ItemDatabase.asset");
            AssetDatabase.SaveAssets();

            EditorUtility.FocusProjectWindow();

            Selection.activeObject = itemDatabase;
        }
        blockDatabase = AssetDatabase.LoadAssetAtPath <BlockDatabaseScriptableObject>("Assets/Scripts/Database/BlockDatabase.asset");
        minSize       = new Vector2(540f, 300f);
    }
    void OnEnable()
    {
        EditorApplication.playModeStateChanged += OnPlayModeChanged;
        blockDatabase = AssetDatabase.LoadAssetAtPath <BlockDatabaseScriptableObject>("Assets/Scripts/Database/BlockDatabase.asset");
        if (blockDatabase == null)
        {
            blockDatabase = ScriptableObject.CreateInstance <BlockDatabaseScriptableObject>();

            AssetDatabase.CreateAsset(blockDatabase, "Assets/Scripts/Database/BlockDatabase.asset");
            AssetDatabase.SaveAssets();

            EditorUtility.FocusProjectWindow();

            Selection.activeObject = blockDatabase;
        }
        itemDatabase = AssetDatabase.LoadAssetAtPath <ItemDatabaseScriptableObject>("Assets/Scripts/Database/ItemDatabase.asset");
        minSize      = new Vector2(540f, 390f);
    }