Esempio n. 1
0
    private void ImportItems()
    {
        using (var reader = new StreamReader(AssetDatabase.GetAssetPath(itemsFile)))
        {
            while (!reader.EndOfStream)
            {
                var line   = reader.ReadLine();
                var values = line.Split(',');


                if (values[2] == "Raw")
                {
                    Debug.Log("Raw Item/n" +
                              "Name: " + values[1] + ", Img: " + values[3]);

                    Raw rawItem = CreateRaw(values[1]);
                    //rawItem.rarity = setRarityByName(values[4]);
                }

                if (values[2] == "Refined")
                {
                    Debug.Log("Refined Item/n" +
                              "Name: " + values[1] + ", Img: " + values[3]);

                    Refined rawItem = CreateRefined(values[1]);
                }
                if (values[2] == "Component")
                {
                    Debug.Log("Component Item/n" +
                              "Name: " + values[1] + ", Img: " + values[3]);

                    Component rawItem = CreateComponent(values[1]);
                }
                if (values[2] == "Commerce")
                {
                    Debug.Log("Commerce Item/n" +
                              "Name: " + values[1] + ", Img: " + values[3]);

                    Commerce rawItem = CreateCommerce(values[1]);
                }
            }
        }
    }
Esempio n. 2
0
    public Component CreateComponent(string name)
    {
        Component asset = ScriptableObject.CreateInstance <Component>();

        asset.itemName = name;
        Sprite sprite = AssetDatabase.LoadAssetAtPath("Assets/Materials/Textures/items/Components/" + name + "_component_img.png", typeof(Sprite)) as Sprite;

        if (sprite != null)
        {
            asset.sprite = sprite;
        }
        if (!AssetDatabase.IsValidFolder("Assets/Resources/Items/Components"))
        {
            AssetDatabase.CreateFolder("Assets/Resources/Items", "Components");
        }
        AssetDatabase.CreateAsset(asset, "Assets/Resources/Items/Components/" + name + ".asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }