4:04 卡哇伊内
4:04 卡哇伊内
pos坐标的转换将以世界坐标系和黑色方块的物体坐标系为基础进行转换,所以第一次转换的结果是相等的
用反射代替switch语句,解决需求变更问题
Type t = receiver.GetType();
//反射
MethodInfo methodInfo = t.GetMethod("CreateCharacter");
//将特定类型分配给泛型方法定义的类型参数
methodInfo = methodInfo.MakeGenericMethod(soldierType);
//参数数组
object[] parameters = new object[] { weaponType, pos, lv };
methodInfo.Invoke(receiver, parameters);
如果遇到Enable在Awake前面,可以进入script execution order 更改script执行顺序
Layout使用tall布局
切割的方法:
TextType选择Sprite(2D and UI
Sprite选择Multiple
选择 Open Sprite Editor
然后点击yes 选择 slice 的automatic
自动进行切割
做游戏可以不使用框架?可以
弊端:
1.不方便协同开发
2.不方便维护
打包出错:
Assets\XLua\Gen\UnityEngine_LightWrap.cs(191,39): error CS1061: 'Light' does not contain a definition for 'SetLightDirty'
解决办法:
https://blog.csdn.net/xiaochenXIHUA/article/details/96910189
CMake报错解决:
Visual Studio Installer--修改:
1、单个组件--2个包含CMake的组件;
2、单个组件--window10 SDK
3、工作负荷--Visual Studio 扩展开发;
然后 CMake--File--Delete Cache ,重新Configure
1.动静分离
2.合理划分UI层级
3.尽量减少mask使用
4.尽量减少图文交叉
5.尽量少使用Raycast Target属性
6.图片可以打包成图集,九宫格
7.图片压缩
或者关闭按钮点击事件
//关闭排行榜面板,清空子物体
private void OnCloseButtonClick()
{
transform.DOScale(Vector3.zero,0.3f);
//关闭排行榜面板,清空子物体
for (int i = 0; i < m_Parent.childCount; i++)
{
Destroy(m_Parent.GetChild(i).gameObject);
}
}
PanelDisplayedLayer
//判断当前点和目标点的距离
if(Vector2.Distance(transform.position,roadsTrans[index+1].position)<0.05f)
//定义最后一个索引
//if(index == finalIndex){
if(Vector2.Distance(transform.position,roadsTrans[finalIndex].position)<0.1f){return;}
}
//判断在后,移动在前
foreach循环遍历中不能修改遍历dui x
ci chu为什么用反射调用方法
//1.修改stone脚本的CreateTears方法
private void CreateTears(){
tearNum++;
GameObject go = Instantiate(tearsGo,roadsTrans[0].position,Quaternion.identity);
Tear tear = go.GetComponent<Tear>();
tear.pointsTrans = pointTrans;
}
//2.把眼泪的层级改成2
//3.新建脚本Tear
public class Tear:MonoBehaviour
{
public Transform[] pointsTrans;
void Update()
{
Vector2.MoveTowards(transform.position,)
}
}
Tear脚本
public Transform[] roadsTrans;
void Update(){
Vector2.MoveTowards(transform.posistion,roadsTrans[roadsTrans.Length-1].posistion,0.02f);
}
获取Points下的子路点:
两种方法
方法1:
tearsGo = Rescources.Load<GameObject>("Prefabs/Tear");
transform.Find("Points").GetChild(0);
transform.Find("Points").GetChild(0-n);
方法2:定义一个数组,存放子路点
private Transform[] pointsTrans;
void Start(){
tearsGo = Rescources.Load<GameObject>("Prefabs/Tear");//加载资源预制体
Transform pointTrans = trans.Find("Points");
//寻找父路点
pointsTrans = new Transform[pointTrans.childCount];//初始化路点数组,数组大小是父节点的数目
for(int i=0;i<pointsTrans.Length;i++)
{
//把子路点加进去
pointsTrans[i] = pointsTrans.getChild(i);
}
foreach(var item in pointsTrans)
{
Debug.Log(item);
}
}
Invoke(Invoke和InvokeRepeating有啥区别)
和携程移动眼泪
private int tearNum;
start(){
...
Invoke("StartcreatingTears",6);
}
// 定义一个方法
private void CreateTear(){
tearNum++;
Instantiate(tearsGo,roadsTrans[0]);
}
//每次生成一滴眼泪
private void StartcreatingTears(){
//从第0s开始,每隔2s开始调用一次方法
InvokeRepeating("CreateTear",0,2)
}
//眼泪数量限制,到达数量了停掉
void Update(){
if(tearNum>=5){
CancelInvoke();
tearNum = 0;
}
}
prefabs预制体文件夹的创建
拖动tear文件到prefabs中变成预制体
stone脚本挂在石像上
使用resource.Load<>加载预制体
a.先定义一个初始变量
private GameObject tearsGo;
b.加载资源
tearsGo = Resources.Load<GameObject>("Prefabs/Tear");
创建几个空游戏对象,作为tears的lu'dian
组件Trail Renderer 拖尾效果
材质的设置Materials选择一个材质
持续时间0.6
拖尾效果的修改,贝塞尔qu'xian(0.02-->0)