0

私はunity3Dゲームエンジンで単語ゲームを作成しています。単語のスペルが間違っている場合は単語を作成します正しいスペルを作成するためにその単語から特定の文字を削除し、他の文字を元に戻したい...私のコードには文字列から文字を削除したい....文字が文字列の中心から削除されると、他の文字が元に戻るようにします。

static var nextPos = 200;
static var word: String;
var sel: String;
var isClicked : boolean=false;
var xpos: float = 200;
static var i:int=0;
function start()
{
 word="";
}
function OnMouseDown()
{
    if (!isClicked) {
       isClicked = true;
       xpos = nextPos;
       sel=OnGUI();
       word=word+sel;
       nextPos += 8;
       i++;

      }
else if(isClicked)
  {
  isClicked = false;
  xpos = nextPos;
  nextPos -= 8;

}
}
function OnGUI()
{  

   if (gameObject.name == "Sphere(Clone)" && isClicked )
   {
          GUI.Label(new Rect(xpos,260,400,100), "A");
          return "A";


   }

   else if (gameObject.name == "Sphere 1(Clone)" && isClicked )
   {
          GUI.Label(new Rect(xpos,260,400,100), "B");
          return "B";

   }  

   else if (gameObject.name == "Sphere 2(Clone)" && isClicked )
   {
          GUI.Label(new Rect(xpos,260,400,100), "C");
          return "C";

   }

  GUI.Label(new Rect(xpos,280,400,100), "Value" + i);
  GUI.Label(new Rect(xpos,300,400,100), word);                      
}
4

2 に答える 2