- Home /
Question by
convictcartel · Jul 22, 2015 at 07:47 AM ·
buttonphotonscriptingbasicslogin
Photon Login Button
I have a photon script that has a login button im trying to change into a differnt button. Theres a code calling a start button text & Im sort of stuck.. Hoping I can get some help. I want this button to load the character into the world when play is clicked
protected virtual void Start()
{
if (GameObject.Find("PlayerInfo") != null)
{
SaveInfo = GameObject.Find("PlayerInfo").GetComponent<bl_SaveInfo>();
m_DefaultPlayerName = SaveInfo.m_UserName;
StartButtonText = GameObject.Find("Login").GetComponent<bl_SaveInfo>();
vp_MPConnection.StayConnected = false;
Chat.enabled = false;
vp_GlobalEventReturn<string>.Register("PlayerName", GetPlayerName);
}
// m_DefaultPlayerName = m_PlayerName;
//m_DefaultStartButtonText = m_StartButtonText;
//vp_MPConnection.StayConnected = false;
// m_Quality = QualitySettings.GetQualityLevel();
if(DontDestroyOnLoad)
Object.DontDestroyOnLoad(transform.root.gameObject);
}
/// <summary>
///
/// </summary>
protected virtual void OnGUI()
{
GUI.depth = 1;
m_TargetSplashColor.a = ((PhotonNetwork.connectionStateDetailed == PeerState.Joined) ? 0.0f : 1.0f);
m_CurrentSplashColor.a = Mathf.Lerp(m_CurrentSplashColor.a, m_TargetSplashColor.a, Time.deltaTime * 1.0f);
if (Splash != null)
{
if (m_CurrentSplashColor.a > 0.01f)
{
//Debug.Log("drawing");
GUI.color = m_CurrentSplashColor;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Splash);
GUI.color = Color.white;
}
}
if (PhotonNetwork.connectionStateDetailed == PeerState.Joined)
return;
GUI.SetNextControlName("1");
Vector2 startPos = new Vector2((Screen.width / 2) - (Screen.width / 3.5f), (Screen.height / 2) - (Screen.height / 3.5f));
DrawButton(m_StartButtonText, startPos, new Vector2((Screen.width / 4), (Screen.height / 9)),
ButtonStyle, m_StartButtonColor, Color.clear, BgTexture, delegate()
{
if ((RequireSetName == true) && (m_PlayerName == m_DefaultPlayerName))
{
m_NameColor = Color.red;
vp_Timer.In(1, delegate()
{
m_NameColor = Color.white;
});
return;
}
if(FindObjectOfType<vp_MPConnection>() == null)
{
m_StartButtonText = "No MP scripts ...";
m_StartButtonColor = Color.red;
vp_Timer.In(1, delegate()
{
m_StartButtonColor = Color.white;
m_StartButtonText = m_DefaultStartButtonText;
});
return;
}
m_StartButtonText = "Connecting ...";
vp_Timer.In(0.1f, delegate()
{
vp_MPConnection.StayConnected = true;
Chat.enabled = true;
GUI.FocusControl("1");
m_UserPressedConnect = true;
while (m_PlayerName.Length < 3)
{
m_PlayerName = "#" + m_PlayerName;
}
});
});
GUI.enabled = !m_UserPressedConnect;
m_Pos.x = startPos.x;
m_Pos.y += Screen.height / 50;
DrawTextField("Name: ", m_Pos, new Vector2((Screen.width / 4), (Screen.height / 9)),
ButtonStyle, m_NameColor, Color.clear, BgTexture);
m_Pos.x = startPos.x;
m_Pos.y += Screen.height / 50;
DrawButton(m_FullScreenButtonText, m_Pos, new Vector2((Screen.width / 4), (Screen.height / 9)),
ButtonStyle, Color.white, Color.clear, BgTexture, delegate()
{
ToggleFullscreen();
m_FullScreenButtonText = (Screen.fullScreen ? "Fullscreen" : "Windowed");
});
m_Pos.x = startPos.x;
m_Pos.y += Screen.height / 50;
if(string.IsNullOrEmpty(m_QualityButtonText))
m_QualityButtonText = "Quality: " + m_Qualitys[QualitySettings.GetQualityLevel()];
DrawButton(m_QualityButtonText, m_Pos, new Vector2((Screen.width / 4), (Screen.height / 9)),
ButtonStyle, Color.white, Color.clear, BgTexture, delegate()
{
m_QualityButtonText = "Please wait ...";
m_Quality++;
if (m_Quality > 5)
m_Quality = 0;
vp_Timer.In(0.1f, delegate()
{
QualitySettings.SetQualityLevel(m_Quality, false);
m_QualityButtonText = "Quality: " + m_Qualitys[QualitySettings.GetQualityLevel()];
});
});
m_Pos.x = startPos.x;
m_Pos.y += Screen.height / 50;
DrawButton("Quit", m_Pos, new Vector2((Screen.width / 4), (Screen.height / 9)),
ButtonStyle, Color.white, Color.clear, BgTexture, delegate()
{
Application.Quit();
});
GUI.enabled = true;
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220611232446im_/https://answers.unity.com/themes/thub/images/avi.jpg)