Unity3d 如何在UNITY中的LEVEL UNLOCK系统中禁用纹理?

Unity3d 如何在UNITY中的LEVEL UNLOCK系统中禁用纹理?,unity3d,textures,unityscript,game-loop,Unity3d,Textures,Unityscript,Game Loop,我正在构建一个包含8个关卡的游戏。我使用以下脚本切换下一个级别。但当我解锁一个关卡时,锁定纹理仍保留在窗口中。我想在解锁新关卡时移除锁定纹理。请帮帮我 完整脚本如下所示: var TitleText:String = "SINGLE PLAYER"; var NumberOfPlayers:int = 1; var Levels:int = 8; private var LevelIndex:int = 0; var PointsToUnlock:Array = new Array(0, 2

我正在构建一个包含8个关卡的游戏。我使用以下脚本切换下一个级别。但当我解锁一个关卡时,锁定纹理仍保留在窗口中。我想在解锁新关卡时移除锁定纹理。请帮帮我

完整脚本如下所示:

var TitleText:String = "SINGLE PLAYER";
var NumberOfPlayers:int = 1;

var Levels:int = 8;
private var LevelIndex:int = 0;

var PointsToUnlock:Array = new Array(0, 2, 6, 12, 24, 36, 48, 56);

var LevelsGrid:Vector2 = Vector2(4,2);
private var GridIndexA:int = 0;
private var GridIndexB:int = 0;

var LevelTexture:Texture2D;
var LockTexture:Texture2D;

//~ var HowToPlayTexture:Texture2D;
var BGPattern:Texture2D;

//This script displays the HUD, with current weapon, ammo left, Health, Shield, and score
var GUIskin:GUISkin; //The skin gui we'll use

private var LevelPoints:Array = new Array();
private var TotalPoints:int = 0;

function Start()
{
    if ( camera.main.GetComponent("StartMenu") )
        camera.main.GetComponent("StartMenu").MenuLevel = transform;
    else if ( camera.main.GetComponent("EndMenu") )
        camera.main.GetComponent("EndMenu").MenuLevel = transform;

    LevelPoints.Clear();

    for ( LevelIndex = 1 ; LevelIndex <= transform.GetComponent("LevelsMenu").Levels ; LevelIndex++ )
    {
        LevelPoints.Push(PlayerPrefs.GetInt(("level" + LevelIndex + "Points").ToString()));

        TotalPoints += LevelPoints[LevelIndex - 1];
    }

    print(LevelPoints);
    print(TotalPoints);
}

function OnGUI()
{
    GUI.skin = GUIskin; //The skin gui we'll use
    GUI.depth = 0;

    GUI.DrawTexture(Rect( 0, 0 ,Screen.width, Screen.height), BGPattern);//Laps.ToString() + "/" + GameController.GetComponent("GameController").LapsToWin.ToString()); //Draw the HUD texture

    GUI.Label(Rect(0, 10, Screen.width, 70), TitleText);

    LevelIndex = 0;

    for ( GridIndexB = 0 ; GridIndexB < LevelsGrid.y ; GridIndexB++ )
    {
        for ( GridIndexA = 0 ; GridIndexA < LevelsGrid.x ; GridIndexA++ )
        {
            LevelIndex++;

            GUI.DrawTexture(Rect( (Screen.width - LevelsGrid.x * (LevelTexture.width + 10)) * 0.5 + GridIndexA * (LevelTexture.width + 10), 60 + GridIndexB * (LevelTexture.height + 10) ,LevelTexture.width, LevelTexture.height), LevelTexture);//Laps.ToString() + "/" + GameController.GetComponent("GameController").LapsToWin.ToString()); //Draw the HUD texture

            if ( TotalPoints >= PointsToUnlock[LevelIndex - 1] )
            {
                if ( GUI.Button(Rect( (Screen.width - LevelsGrid.x * (LevelTexture.width + 10)) * 0.5 + GridIndexA * (LevelTexture.width + 10), 60 + GridIndexB * (LevelTexture.height + 10), LevelTexture.width, LevelTexture.height), LevelIndex.ToString()) )//Laps.ToString() + "/" + GameController.GetComponent("GameController").LapsToWin.ToString()); //Draw the HUD texture
                {
                    PlayerPrefs.SetInt("currentLevel", LevelIndex); 
                    Application.LoadLevel("level" + LevelIndex);

                }
            }
            else
            {
                GUI.DrawTexture(Rect( (Screen.width - LevelsGrid.x * (LevelTexture.width + 10)) * 0.5 + GridIndexA * (LevelTexture.width + 10), 60 + GridIndexB * (LevelTexture.height + 10), LevelTexture.width, LevelTexture.height), LockTexture);
            }
        }
    }

    if ( GUI.Button(Rect( 10, Screen.height - 70, 140, 60), "BACK") )//Laps.ToString() + "/" + GameController.GetComponent("GameController").LapsToWin.ToString()); //Draw the HUD texture
    {
        if ( camera.main.GetComponent("StartMenu") )
            camera.main.GetComponent("StartMenu").MenuLevel = camera.main.transform;
        else if ( camera.main.GetComponent("EndMenu") )
            camera.main.GetComponent("EndMenu").MenuLevel = camera.main.transform;

        Destroy(gameObject);
    }

    if ( GUI.Button(Rect( Screen.width - 410 , Screen.height - 70, 400, 60), "RESET LEVELS") )//Laps.ToString() + "/" + GameController.GetComponent("GameController").LapsToWin.ToString()); //Draw the HUD texture
    {
         LevelPoints.Clear();

         for ( LevelIndex = 1 ; LevelIndex <= transform.GetComponent("LevelsMenu").Levels ; LevelIndex++ )
         {
             PlayerPrefs.SetInt(("level" + LevelIndex + "Points").ToString(), 0);
         }

        //~ TotalPoints = 0;
    }
}
在下面的循环中,我只需要一行简单的代码,当出现新级别时,我可以在其中禁用LockTexture:

LevelIndex = 0;

    for ( GridIndexB = 0 ; GridIndexB < LevelsGrid.y ; GridIndexB++ )
    {
        for ( GridIndexA = 0 ; GridIndexA < LevelsGrid.x ; GridIndexA++ )
        {
            LevelIndex++;

            GUI.DrawTexture(Rect( (Screen.width - LevelsGrid.x * (LevelTexture.width + 10)) * 0.5 + GridIndexA * (LevelTexture.width + 10), 60 + GridIndexB * (LevelTexture.height + 10) ,LevelTexture.width, LevelTexture.height), LevelTexture);//Laps.ToString() + "/" + GameController.GetComponent("GameController").LapsToWin.ToString()); //Draw the HUD texture

            if ( TotalPoints >= PointsToUnlock[LevelIndex - 1] )
            {
                if ( GUI.Button(Rect( (Screen.width - LevelsGrid.x * (LevelTexture.width + 10)) * 0.5 + GridIndexA * (LevelTexture.width + 10), 60 + GridIndexB * (LevelTexture.height + 10), LevelTexture.width, LevelTexture.height), LevelIndex.ToString()) )//Laps.ToString() + "/" + GameController.GetComponent("GameController").LapsToWin.ToString()); //Draw the HUD texture
                {
                    PlayerPrefs.SetInt("currentLevel", LevelIndex); 
                    Application.LoadLevel("level" + LevelIndex);

                }
            }
            else
            {
                GUI.DrawTexture(Rect( (Screen.width - LevelsGrid.x * (LevelTexture.width + 10)) * 0.5 + GridIndexA * (LevelTexture.width + 10), 60 + GridIndexB * (LevelTexture.height + 10), LevelTexture.width, LevelTexture.height), LockTexture);
            }
        }
    }

不需要在这里提出新问题,最好在同一个问题中编辑相同的问题。。。还在这个地方堆积。。。