Unity 一直给我这个错误代码,但它以前有效?

问题描述 投票:0回答:1

error CS1525: 无效的表达式术语 ')' 这是一个基本的相机触发代码,应该用于电影机固定的静态镜头 去年工作,现在不再工作了?

我的代码有问题还是 unity 发疯了?还是我疯了?

这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
using System.Media;

public class ShotZone : MonoBehaviour
{
    CinemachineVirtualCamera currentCamera;
    Player player;

    public CinemachineVirtualCamera targetCamera;

    void Start()
    {
        player = FindObjectOfType<Player>();
    }


    void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            SceneChange();
        }
    }

    void SceneChange()
    {
        if (GameObject.FindGameObjectWithTag("CurrentCamera") != null)
        {
            if (GameObject.FindGameObjectWithTag("CurrentCamera").GetComponent<CinemachineVirtualCamera<() != null)
            {
                currentCamera = GameObject.FindGameObjectWithTag("CurrentCamera").GetComponent<CinemachineVirtualCamera>();
            }
        }
        else
        {
            currentCamera = null;
        }

        if (currentCamera != targetCamera || currentCamera == null) ;
        {
            targetCamera.tag = "CurrentCamera";
            targetCamera.Priority = 100;

            currentCamera.tag = "InactiveCamera";
            currentCamera.Priority = 99;
        }
    }
}

c# unity3d
1个回答
2
投票

这是错误的一行——一个简单的错字。您在下一行缺少 >

if (GameObject.FindGameObjectWithTag("CurrentCamera").GetComponent<CinemachineVirtualCamera<() != null) { }

应该是这样

if (GameObject.FindGameObjectWithTag("CurrentCamera").GetComponent<CinemachineVirtualCamera>() != null) { }
© www.soinside.com 2019 - 2024. All rights reserved.