- Home /
Question by
RamiT · Jan 09, 2014 at 07:43 AM ·
javascriptvariablestringreplace
How to edit string? How to add text to string?
I do have buttons 1-9 and they should add number to string when button is pressed, I just don't have any idea how to do that, I tried int variable and It works with buttons, but how to add numbers to string?
Something like that, if button 1 is pressed then add 1 and when pressed button again add number after 1. etc. Also how to clear string?
var password="";
var passwordUser="";
var passwordTest : int;
//var script:doorScript;
//var passwLight:lightIntensity;//script
function OnGUI(){
GUI.Label(new Rect(Screen.width/2 - 75, Screen.height - 120, 150, 30), "Password:"+passwordUser);
}
//}
function Button1 (){
animation.Play("nappi1");
passwordTest++;
}
Comment
Best Answer
Answer by Polymo · Jan 09, 2014 at 07:56 AM
i hope this is what you want:
int number = 1;
Debug.Log(string.Format("blabla: {0}", number));
Debug.Log("blabla: "+number.ToString());
or if you wanted something like "test111"; you can just do:
int number = 1;
string numbertext = "";
numbertext = numbertext+ number.ToString(); //to add number
Debug.Log("blabla: "+numbertext); //to combine
numbertext = ""; //to clear;
Your answer
Follow this Question
Related Questions
SOLVED - String replace % with " in C# 1 Answer
Variable in String 1 Answer
Best way to emulate Swift String Interpolation in UnityScript? 1 Answer
Finding A Variable With A String Variable 1 Answer
On Button press Move Value toward 2 Answers