36 lines
805 B
C#
36 lines
805 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
public enum ImageType
|
|
{
|
|
None,
|
|
行人,
|
|
红绿灯,
|
|
车辆
|
|
}
|
|
public class LookAtCamera : MonoBehaviour
|
|
{
|
|
public ImageType imageType = ImageType.None;
|
|
public GameObject chirenimage;
|
|
void Start()
|
|
{
|
|
chirenimage = transform.GetChild(0).gameObject;
|
|
if (transform.parent.gameObject.CompareTag("People"))
|
|
{
|
|
imageType = ImageType.行人;
|
|
}
|
|
if (transform.parent.gameObject.CompareTag("Car"))
|
|
{
|
|
imageType = ImageType.车辆;
|
|
}
|
|
if (transform.parent.gameObject.CompareTag("红绿灯"))
|
|
{
|
|
imageType = ImageType.红绿灯;
|
|
}
|
|
}
|
|
void Update()
|
|
{
|
|
transform.LookAt(Camera.main.transform);
|
|
}
|
|
}
|