Beispiel #1
0
    void AddProductToList(AppcoinsSku product)
    {
        //Get the AppcoinsUnity script component
        AppcoinsUnity[] objs     = FindObjectsOfType <AppcoinsUnity>();
        AppcoinsUnity   appcoins = objs[0];

        //Check if product is in the list, if it isn't add it!
        bool found = false;

        foreach (AppcoinsSku existingProduct in appcoins.products)
        {
            if (existingProduct == product)
            {
                found = true;
                break;
            }
        }

        if (!found)
        {
            int length = appcoins.products.Length;

            AppcoinsSku[] newProducts = new AppcoinsSku[length + 1];
            int           i           = 0;
            foreach (AppcoinsSku existingProduct in appcoins.products)
            {
                newProducts[i++] = existingProduct;
            }
            newProducts[i]    = product;
            appcoins.products = newProducts;
        }
    }
Beispiel #2
0
    private void FindAppcoinsGameObject()
    {
        AppcoinsUnity[] foundObjects = (AppcoinsUnity[])
                                       UnityEngine.Object.FindObjectsOfType(typeof(AppcoinsUnity));

        if (foundObjects.Length == 0)
        {
            throw new Exception(new ASFAppcoinsGameObjectNotFound().message);
        }

        asfGameObject = foundObjects[0];
    }