小编Dan*_*oni的帖子

如何获取鼠标移动事件?

我希望移动鼠标光标时会发生一些事情。但我不确定会举办什么活动。是否有任何 onmousemove 事件或者我应该以某种方式使用 onmousedown 和 onmouseup ?

感谢您的帮助。

using UnityEngine;
using System.Collections;

[AddComponentMenu("Camera-Control/Mouse Orbit with zoom")]
public class MouseOrbitImproved : MonoBehaviour
{
    public Transform target;
    public float distance = 5.0f;
    public float xSpeed = 120.0f;
    public float ySpeed = 120.0f;

    public float yMinLimit = 3.0f;//-20f;
    public float yMaxLimit = 80f;

    public float distanceMin = .5f;
    public float distanceMax = 15f;

    private Rigidbody rigidbody;

    float x = 0.0f;
    float y = 0.0f;

    public float rotationSpeed = 5f;

    // Use this for …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

1
推荐指数
1
解决办法
4281
查看次数

如何检测角色是否已经在另一个游戏对象中?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour {

    enum MoveProperties
    {
        DirectionStart,
        DirectionEnd
    };

    public float spinSpeed = 2.0f;

    private bool rotate = false;
    private bool exited = false;
    private List<GameObject> prefabs;

    private void Start()
    {
        InstantiateObjects gos = GetComponent<InstantiateObjects>();

        prefabs = new List<GameObject>();
        prefabs = gos.PrefabsList();
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            Debug.Log("Player entered the hole");
            rotate = true;
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "Player")
        { …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine unity5

0
推荐指数
1
解决办法
58
查看次数

标签 统计

c# ×2

unity-game-engine ×2

unity5 ×1