private void LoadFood()
    {
        string curFood;

        for (int i = 0; i < 5; i++)
        {
            curFood = SelectedFood.getInstance().GetFoodList()[i];

            try
            {
                if (curFood.Equals(""))
                {
                    continue;
                }
                // instantiate prefab
                GameObject foodObject = Instantiate(Resources.Load <GameObject>("Prefabs/" + curFood)) as GameObject;
                // setPosition & size
                foodObject.transform.localScale    = foodTr.scale;
                foodObject.transform.localPosition = foodTr.pos[i];
                foodObject.AddComponent <MouseEvent>();

                DontDestroyOnLoad(foodObject);
            }
            catch (Exception e)
            {
                Debug.Log(curFood + ":is not available");
                Debug.Log(e.Message);
            }
        }
    }
Exemplo n.º 2
0
        private void Awake()
        {
            plateConfig  = gameObject.AddComponent <PlateConfig>(); //new PlateConfig();
            listview     = gameObject.AddComponent <Listview>();
            searchConfig = gameObject.AddComponent <SearchConfig>();
            changeScene  = gameObject.AddComponent <ChangeScene>();
            selectedFood = SelectedFood.getInstance();

            searchConfig.setListview(listview, searchConfig, this);
            plateConfig.PlateButtonListener(searchConfig, this);
        }