unity遇到的问题

unity遇到的问题

实现需求-----开门的脚本

按下z键就会开门 抬起就会关门,使用组件 Transform.Rotation(vector float)

使用transform组件的rotate的(轴,旋转度数)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
​
public class opendoor : MonoBehaviour
{
    private Transform m_transform;
    // Start is called before the first frame update
    void Start()
    {
        //获取transform组件
        m_transform = gameObject.GetComponent<Transform>();
    }
​
    // Update is called once per frame
    void Update()
    {
        if (Input.Getkeydown(keyCode.z))
        {
            //opend
            OpenDoor();
        }
        if(Input.GetKeyUP(KeyCode.z))
        {
            //close
            CloseDoor();
        }
    }
    void OpenDoor()
    {
        m_transform.Rotate(vector3.up, 90);
    }
    void CloseDoor()
    {
        m_transform.Rotate(vector3.up, -90);
    }
}
​

导入的fbx格式的不同物件

cannot restructure prefab instance chdren of aprefabnstance camotbe deeted ormoved, and components cannot be reordered,you can unpack the prefab instance to remove itsprefab conmection. ok

报错

但是无法编辑单独物件


解决方案

在预制体右键 解除

需要解除预制体的

怎么移动轴心??

直接新建空物体,然后直接在privot的模式,移动空物体的轴心,移动好位置在 再拉子物体进来

怎么设置游戏的摄像机机

新建摄像机

然后自场景screen的地方直接调节摄像机的位置

再回到game游戏的窗口看一下

怎么使用till瓦片贴图

新建一个planer

然后新建一个材质

接着使用贴图

vs编辑unitu的c#显示不兼容

VS 下载unity的插件但是还是不行

明天看看是否是.net不兼容还是什么???

猜你喜欢

转载自blog.csdn.net/weixin_70271498/article/details/126839242