接加工订单的网站,设计素材网站图案免费,如何查询网站的域名注册,网站优化可以做哪些优化1.发现一个非常实用的功能#xff0c;点击unity中console的输出项#xff0c;可以直接跳转到vs的代码页#xff01;
2.static类#xff08;变量#xff09;有三个特点#xff1a;
#xff08;1#xff09;独一份#xff08;2#xff09;无法实例化。#xff08;3点击unity中console的输出项可以直接跳转到vs的代码页
2.static类变量有三个特点
1独一份2无法实例化。3全局。类似于c语言中的全局变量。
3.应用因为create的panel在初始化时是false的无法通过select脚本来find这个问题之前出过。这次在create初始化时直接用static变量来记录panel的指针。再在create点击“创建角色”按钮时将其弹出。
create部分的代码如下
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;public class CreatePlayerPanel : MonoBehaviour
{//TMP_Text a GameObject.FindWithTag(username).GetComponentTMP_Text();--不能写这里public static GameObject panel;//这是个全局变量--实例类private int job;//当前所选角色// Start is called before the first frame updatevoid Start(){Debug.Log(CreatePlayerPanel获取object测试--这个在游戏加载的时候就执行了最最最开始大的时候);panel GameObject.FindWithTag(createPanel);//同一命名空间即可canvas在最外边是有道理的panel.SetActive(false);}// Update is called once per framevoid Update(){}public void finish(){panel.SetActive(false);//点击}public void selectJob(int job)//职业-我就纳闷昵称在哪里{//选择职业}
}select部分的代码如下
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class SelectMenu : MonoBehaviour
{// Start is called before the first frame update//public GameObject c GameObject.FindWithTag(selectMenuCanvas);public GameObject quan;//start中就保存好了public int flag 0;void Start(){//gameObject.SetActive(false);//GameObject m GameObject.FindWithTag(selectMenuCanvas);//现在我挂在camera上就可以这么用了this.quan GameObject.FindWithTag(selectMenuCanvas);//同一命名空间即可canvas在最外边是有道理的this.quan.SetActive(false);//gameObject.GetComponentRenderer.enabled false;}// Update is called once per framevoid Update()//角色的选择和创建我做在一起就可以了{//Debug.Log(GameInfo.GAME_STATE);//初始状态开始为0//Debug.Log(GameState.PLAYER_CREATE); //这个是4if (GameInfo.GAME_STATE GameState.PLAYER_CREATE this.flag 0){//Debug.Log(GameInfo.GAME_STATE);//初始状态开始为0//Debug.Log(GameState.PLAYER_CREATE);this.flag 1;Debug.Log(这里计划是只执行一次);this.quan.SetActive(true);}}public void GoToCreate()//unity那边想要加载必须public{Debug.Log(我确实进入onclick函数了);//这种藏起来的找不着第二次犯这个错误了//下面这两句再次说明了之前false的找不到//GameObject panel GameObject.FindWithTag(createPanel);//同一命名空间即可canvas在最外边是有道理的//panel.SetActive(true);Debug.Log(CreatePlayerPanel.panel);CreatePlayerPanel.panel.SetActive(true);//用的static实例类--这个卡住了Debug.Log(给我弹出创造页面);}
}这东西难在对static的理解和应用。