0

how to remove coma "," from first word in c# unity

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Test : MonoBehaviour { public InputField inputField; public Button Add1; public Button Add2; GameObject Panel; GameObject PanelText1; GameObject PanelText2; GameObject InputField; //bool Addtext = true; //bool Addtext2 = true; public List<string> words = new List<string>(); public List<string> word = new List<string>(); // Start is called before the first frame update void Start() { Add1 = GameObject.Find("/Canvas/Panel/Add1").GetComponent<Button>(); Add1.onClick.AddListener(InputText1); Add2 = GameObject.Find("/Canvas/Panel/Add2").GetComponent<Button>(); Add2.onClick.AddListener(InputText2); PanelText1 = GameObject.Find("/Canvas/Panel/Text1"); PanelText2 = GameObject.Find("/Canvas/Panel/Text2"); InputField = GameObject.Find("/Canvas/InputField"); } public void InputText1() { words.Add(InputField.GetComponent<InputField>().text); InputField.GetComponent<InputField>().text = " "; PanelText1.GetComponent<Text>().text = " "; for (int i = 0; i < words.Count; i++) { PanelText1.GetComponent<Text>().text += ("," + words[i]); } } public void InputText2() { word.Add(InputField.GetComponent<InputField>().text); InputField.GetComponent<InputField>().text = " "; PanelText2.GetComponent<Text>().text = " "; for (int i = 0; i < word.Count; i++) { PanelText2.GetComponent<Text>().text += "," +( word[i]); }

25th Feb 2021, 6:17 AM
Mohammad Yahya Azhar
Mohammad Yahya Azhar - avatar
1 Respuesta
+ 2
The code is truncated because it's too large to fit in Description. I think you better describe what you want to do, and show a snippet focusing on just the part that you need help with. Or, you can save your code in SoloLearn, and share its link instead. But I'm not sure whether that will help, because SoloLearn only supports console code, while your code depends on Unity GUI (as it seems).
25th Feb 2021, 6:26 AM
Ipang