public void ApplyButtonOnClick(Toggle toggle) { string finilisedList; if (toggle.isOn.Equals(true)) { YellowStateMachinesList[counter].errorState = "2"; if (counter == size) { //Send Updated List to the server //Load Optimised List Scene // finilisedList = JsonUtility.ToJson(YellowStateMachinesList); finilisedList = JsonUtility.ToJson(YellowStateMachinesList); JsonEntity jsonEntity = new JsonEntity(); jsonEntity.JsonFlag = "OptimisationRequest"; jsonEntity.JsonObject = finilisedList; string optimisationMessage = JsonUtility.ToJson(jsonEntity); OptimisedListCommunication optimisedListCommunication = new OptimisedListCommunication(); optimisedListCommunication.SendDataToServer(optimisationMessage); SceneManager.LoadScene("OptimisedRoot"); } else { GameObject newMachine = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newMachine.GetComponent <ListItemController>(); controller.MachineId.text = YellowStateMachinesList[counter + 1].id; controller.OperationToDo.text = YellowStateMachinesList[counter + 1].operationToDo; newMachine.transform.parent = ContentPanel.transform; newMachine.transform.localScale = Vector3.one; counter++; } } else { YellowStateMachinesList[counter].errorState = "0"; if (counter == size) { //Send Updated List to the server //Load Optimised List Scene finilisedList = JsonUtility.ToJson(YellowStateMachinesList); JsonEntity jsonEntity = new JsonEntity(); jsonEntity.JsonFlag = "OptimisationRequest"; jsonEntity.JsonObject = finilisedList; string optimisationMessage = JsonUtility.ToJson(jsonEntity); OptimisedListCommunication optimisedListCommunication = new OptimisedListCommunication(); optimisedListCommunication.SendDataToServer(optimisationMessage); SceneManager.LoadScene("OptimisedRoot"); } else { GameObject newMachine = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newMachine.GetComponent <ListItemController>(); controller.MachineId.text = YellowStateMachinesList[counter + 1].id; controller.OperationToDo.text = YellowStateMachinesList[counter + 1].operationToDo; newMachine.transform.parent = ContentPanel.transform; newMachine.transform.localScale = Vector3.one; counter++; } } }
void Start() { Object[] textures = Resources.LoadAll <Sprite>(imagePath); ResultImages = new Sprite[textures.Length]; for (int i = 0; i < textures.Length; i++) { ResultImages[i] = (Sprite)textures[i]; } Debug.Log("Textures Loaded: " + ResultImages.Length); Debug.Log("Image Path: " + imagePath); foreach (Sprite animal in ResultImages) { GameObject element = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = element.GetComponent <ListItemController>(); controller.Icon.sprite = animal; element.transform.parent = ContentPanel.transform; element.transform.localScale = Vector3.one; } // 2. Iterate through the data, // instantiate prefab, // set the data, // add it to panel }
void OnFillItem(int index, GameObject item) { ListItemController itemController = item.GetComponentInChildren <ListItemController>(); Place place = currentData.Places[index]; // Async load StartCoroutine(itemController.LoadItem(place)); }
/// <summary>clears all text in all list items and sets data count to zero</summary> public void Clear() { dataCounter = 0; foreach (Transform itemTransf in ContentPanel.transform) { ListItemController itemController = itemTransf.GetComponent <ListItemController>(); itemController.dataText.text = ""; } }
public void TestMethod1() { var controller = new ListItemController(); controller.Post(1, new List <ListItem> { new ListItem { Id = "aisdf", Description = "Hello World", Complete = true, ModifiedUTC = 8 } }); }
private void UpdateProjectListOnScreen() { foreach (Project p in ProjectList) { GameObject newListItem = Instantiate(ListElementPrefab, ListElementContainer.transform); newListItem.name = p.id; ListItemController currentItemController = newListItem.GetComponent <ListItemController>(); currentItemController.SetupListItem(p); } }
void callback(PolyAsset asset, PolyStatus status) { GameObject newAnimal = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newAnimal.GetComponent<ListItemController>(); controller.Icon.GetComponent<Renderer>().material.mainTexture = asset.thumbnailTexture; controller.Name.GetComponent<TextMesh>().text = asset.displayName; newAnimal.transform.parent = ContentPanel.transform; newAnimal.transform.localScale = Vector3.one; }
///<summary>adds a new data value to the list</summary> public void AddListDataItem(string value) { // increase data item count by one dataCounter++; // get item at bottom of list, move it to top and set value to new data value Transform newItemTranf = ContentPanel.transform.GetChild(ContentPanel.transform.childCount - 1); newItemTranf.SetAsFirstSibling(); ListItemController itemController = newItemTranf.GetComponent <ListItemController> (); itemController.dataText.text = MathScientific.ToMetric((float)dataCounter) + ") " + value; }
void Start() { ui_manager = Object.FindObjectOfType <ListController>(); harvesterUiElement = ui_manager.AddUiElement( Resources.Load <Sprite>("Sprites/" + component.harvesterPrototype), component.harvesterPrototype, cancel => {}); wizardUiElement = ui_manager.AddUiElement( Resources.Load <Sprite>("Sprites/" + component.wizardPrototype), component.wizardPrototype, cancel => {}); }
public void onImportantClick() { int childs = ContentPanel.transform.childCount; for (int j = childs - 1; j >= 0; j--) { GameObject.Destroy(ContentPanel.transform.GetChild(j).gameObject); } ArrayList reports = ApiDataGenerator.getDummyReports(); int i = 0; foreach (Report reportItem in reports) { GameObject newReport = (GameObject)Instantiate(listPrefab, transform.position, Quaternion.identity); ListItemController controller = newReport.GetComponent <ListItemController>(); controller.reporterName.text = reportItem.getReporterName(); controller.Icon.sprite = circleImages[i++]; string reportId = reportItem.getReportId().ToString(); controller.boatName.text = reportItem.getBoatName(); int boatType = reportItem.getBoatType(); if (boatType == 1) { controller.boatType.text = "Waterpolice Officer"; } else if (boatType == 2) { controller.boatType.text = "Undercover Cop"; } else { } controller.like.text = reportItem.getLikeCount().ToString(); controller.dislike.text = reportItem.getDislikeCount().ToString(); string countThanks = reportItem.getThankCount().ToString(); newReport.transform.parent = ContentPanel.transform; newReport.transform.localScale = new Vector3(1, 1, 1); controller.Thank.onClick.AddListener(() => controller.OnThankClick(countThanks, reportId)); controller.likeCount.onClick.AddListener(() => controller.onLikeClick(controller.like.text)); controller.dislikeCount.onClick.AddListener(() => controller.onDislikeClick(controller.dislike.text)); } newestReports.interactable = true; importantReports.interactable = false; }
/** * Method to search and add higher scores. */ public void ChargeHighScores() { for (int i = 0; i < listUsers.Count; i++) { UserScore u = listUsers[i]; GameObject newUser = Instantiate(PreffabListItemUser, ContentPanel.transform) as GameObject; ListItemController lit = newUser.GetComponent <ListItemController>(); lit.name.text = u.name; lit.score.text = u.score.ToString(); lit.time.text = u.time; listItemController.Add(newUser); } }
// Add an Item to the List public void AddToList(string itemName, string shortDesc, bool status, int index) { GameObject newItem = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newItem.GetComponent <ListItemController>(); controller.itemName = itemName; controller.status = status; controller.index = index; newItem.SetActive(true); newItem.transform.GetChild(0).GetComponent <Text> ().text = itemName; newItem.transform.GetChild(2).GetComponent <Text> ().text = shortDesc; newItem.transform.SetParent(ContentPanel.transform, false); }
void createScheduleList() { foreach (Schedule s in schedules) { ListItemPrefab.SetActive(true); GameObject newSchedule = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newSchedule.GetComponent <ListItemController>(); controller.Name.text = s.Name; newSchedule.transform.SetParent(ContentPanel.transform); //newSchedule.transform.localScale = Vector3.one; } schedulesDisplayed = true; }
public void UpdateInventory() { inventoryTitle.text = string.Format("Inventory {0}/{1}", playerScript.inventory.Count, playerScript.inventorySize); foreach (Transform child in inventoryPanel.transform) { Destroy(child.gameObject); } //Update Inventory if (playerScript.inventory.Count > 0) { int invIndex = 0; foreach (GameObject itemObject in playerScript.inventory) { Item item = itemObject.GetComponent <Item>(); GameObject IP = Instantiate(listItemPrefab); ListItemController IC = IP.GetComponent <ListItemController>(); IC.icon.sprite = item.icon; IC.name.text = item.name; IC.invIndex = invIndex; if (item.itemClass == Item.ItemClass.Armour) { Item.ArmourType enumType = (Item.ArmourType)item.itemType; string itemType = enumType.ToString(); IC.description.text = string.Format("Min Damage: {0}\nMax Damage: {1}\nDefence: {2}\nModifier: {3}\nSlot: {4}\n", item.minDamage, item.maxDamage, item.defence, item.modifier, itemType); } else if (item.itemClass == Item.ItemClass.Weapon) { Item.WeaponType enumType = (Item.WeaponType)item.itemType; string itemType = enumType.ToString(); IC.description.text = string.Format("Min Damage: {0}\nMax Damage: {1}\nDefence: {2}\nModifier: {3}\nSlot: {4}\n", item.minDamage, item.maxDamage, item.defence, item.modifier, itemType); } else { Item.Consumeable enumType = (Item.Consumeable)item.itemType; string itemType = enumType.ToString(); IC.description.text = string.Format("Min Damage: {0}\nMax Damage: {1}\nDefence: {2}\nModifier: {3}\nSlot: {4}\n", item.minDamage, item.maxDamage, item.defence, item.modifier, itemType); } IP.transform.SetParent(inventoryPanel.transform); IP.transform.localScale = Vector3.one; invIndex++; } } }
IEnumerator FetchData(string URL) { UnityWebRequest www = UnityWebRequest.Get(URL); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { jsonData = www.downloadHandler.text; JSONNode jsonNode = SimpleJSON.JSON.Parse(jsonData); for (int i = 0; i < jsonNode["response"]["videos"].Count; i++) { GameObject newtemple = Instantiate(ListItemPrefab) as GameObject; newtemple.gameObject.name = jsonNode["response"]["videos"][i]["vid"]; ListItemController controller = newtemple.GetComponent <ListItemController>(); newtemple.transform.parent = ContentPanel.transform; newtemple.transform.localScale = Vector3.one; controller.Name.text = jsonNode["response"]["videos"][i]["title"].ToString(); string getJSONImg = jsonNode["response"]["videos"][i]["preview_url"].ToString(); string replaceQuote = getJSONImg.Replace("\"", ""); string urlImg = replaceQuote.Replace("\\", ""); int total_videos = int.Parse(jsonNode["response"]["total_videos"]); count_page = total_videos / 50; Debug.Log("total_videos: " + count_page); UnityWebRequest wwwTexture = UnityWebRequestTexture.GetTexture(urlImg); yield return(wwwTexture.SendWebRequest()); if (wwwTexture.isNetworkError || wwwTexture.isHttpError) { Debug.Log(wwwTexture.error); } else { Texture2D myTexture = ((DownloadHandlerTexture)wwwTexture.downloadHandler).texture; controller.Icon.sprite = Sprite.Create(myTexture, new Rect(0, 0, myTexture.width, myTexture.height), new Vector2(0, 0)); } } } }
void createLocationsList() { foreach (ScheduleLocation s in locations) { ListItemPrefab.SetActive(true); GameObject newSchedule = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newSchedule.GetComponent <ListItemController>(); controller.Name.text = s.Name; controller.Time.text = s.Time; newSchedule.transform.parent = ContentPanel.transform; newSchedule.transform.localScale = Vector3.one; } locationsDisplayed = true; }
void Start() { testshit = Object.FindObjectOfType <Testshit>(); ui_manager = Object.FindObjectOfType <ListController>(); deployUiElement = ui_manager.AddUiElement( Resources.Load <Sprite>("Sprites/" + component.deployPrototype), component.deployPrototype, cancel => { if (!cancel) { testshit.DeployCommand(GetComponent <EntityMirror>(), // Truck deploys in place. Vector3.zero); } }); }
// Add an Exhibit to the Wishlist public void AddToWishlist(ListItemController item) { if (item.status == false) { item.gameObject.transform.GetChild(1).GetComponent <Image> ().sprite = ListItemActive; Catalogue [item.index].inWishlist = true; Wishlist.Add(Catalogue[item.index]); item.status = true; // status = 1 => Present in Wishlist } else { item.gameObject.transform.GetChild(1).GetComponent <Image> ().sprite = ListItemDisabled; Catalogue [item.index].inWishlist = false; Wishlist.Remove(Catalogue[item.index]); item.status = false; } }
void Start() { testshit = Object.FindObjectOfType <Testshit>(); ui_manager = Object.FindObjectOfType <ListController>(); deployUiElement = ui_manager.AddUiElement( Resources.Load <Sprite>("Sprites/" + component.towerPrototype), component.towerPrototype, cancel => { if (!cancel) { testshit.BeginPlacement(component.towerPrototype, point => testshit.DeployCommand(GetComponent <EntityMirror>(), point), point => component.CheckBuildPlacement((Game.DVector3)point), () => {}); } }); }
public void createTempSchedules() { ArrayList schedules1 = new ArrayList(); schedules1.Add("schedule 0"); schedules1.Add("schedules 1"); foreach (string s in schedules1) { ListItemPrefab.SetActive(true); GameObject newSchedule = Instantiate(ListItemPrefab) as GameObject; gameObjectsList.Add(newSchedule); ListItemController controller = newSchedule.GetComponent <ListItemController>(); controller.Name.text = s; newSchedule.transform.SetParent(ContentPanel.transform); //newSchedule.transform.localScale = Vector3.one; } }
// Use this for initialization IEnumerator Start() { //Items = new ArrayList () { //new Barang ("asd.txt", "asem"), //new Barang ("Abc.txt", "aso"), //new Barang ("adem.txt", "abc") //}; ItemsText = new ArrayList(); WWW www = new WWW(textsUrl); yield return(www); textsNode = (JSONObject)JSON.Parse(www.text); foreach (string key in textsNode.Keys) { Debug.Log(textsNode[key]["uploaderID"]); Debug.Log(PlayerPrefs.GetString("UserEmail")); if (textsNode[key]["uploaderID"].Equals(PlayerPrefs.GetString("UserEmail"))) { WWW temp = new WWW(textsNode[key]["url"]); yield return(temp); ItemsText.Add(new BarangTxt(textsNode[key]["title"], temp.text)); } } foreach (BarangTxt temp in ItemsText) { //Debug.Log (temp.txt); GameObject newItem = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newItem.GetComponent <ListItemController>(); controller.content.text = temp.txt; controller.fname.text = temp.filename; newItem.transform.SetParent(ContentPanel.transform, false); } }
public void LoadList(List <Card> myCards, bool shuffle = true, ClickEffect clickEffect = ClickEffect.nothing, Zones zone = Zones.master, bool forSale = false, bool free = true, int cap = -99) { List <Card> copyOfmyCards = new List <Card>(); int i = 0; copyOfmyCards.AddRange(myCards); if (shuffle) { ShuffleList.Shuffle <Card>(copyOfmyCards); } print(clickEffect); foreach (Card card in copyOfmyCards) { if (clickEffect == ClickEffect.upgrade && card.CanUpgrade == false) { continue; } GameObject newCard = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newCard.GetComponentInChildren <ListItemController>(); controller.myCard = card; controller.icon.sprite = card.mySprite; controller.clickEffect = clickEffect; controller.zone = zone; controller.free = free; if (forSale) { controller.UiText.text = "Cost: " + card.FactoryCost; } newCard.transform.SetParent(ControlPanel.transform, false); newCard.transform.localScale = Vector3.one; i++; if (i >= cap && cap > 0) { break; } } }
// Use this for initialization void Start() { InformationText.text = "These are the yellow stated machines. " + "If you think they have emergency situation " + "please select the machines from the list by clicking to checkbox " + "Checked means Urgent, unchecked means Not Urgent!"; //The data comes from here is a list of Machines. PlantQrCommunication qrCommunication = new PlantQrCommunication(); ServerResponse = qrCommunication.ReceiveDataFromServer(); //Deserilize the received data to MachineEntityList YellowStateMachinesList = JsonUtility.FromJson <List <MachineEntity> >(ServerResponse); Debug.Log(YellowStateMachinesList); // 2. Iterate through the data, // instantiate prefab, // set the data, // add it to panel size = YellowStateMachinesList.Count; if (size == 0) { Debug.Log("This list is empty"); //Send empty list to the server //Call Optimised List in the begining of the next scene SceneManager.LoadScene("OptimmisedRoot"); } else { GameObject newMachine = Instantiate(ListItemPrefab) as GameObject; ListItemController controller = newMachine.GetComponent <ListItemController>(); controller.MachineId.text = YellowStateMachinesList[0].id; controller.OperationToDo.text = YellowStateMachinesList[0].operationToDo; newMachine.transform.parent = ContentPanel.transform; newMachine.transform.localScale = Vector3.one; } }
public ResourceDescriptor(GameObject resourceObject, ListItemController controller, IResource resource) { this.resourceObject = resourceObject; this.controller = controller; this.resource = resource; }