摘要:本文原创,转载请注明出处 需求: 在游戏的任务编辑场景进行编辑的时候,摄像机需要在多个需要编辑的物体之间来回切换,如果只是用摄像机的移动旋转,对于相对位置较近的物体还好说,当相对位置过远的时候,就需要有一个聚焦的功能,可以很方便的自动把相机聚焦到需要编辑物体的一个相对可设置的位置. 如图: 如果有聚焦功能,就可以很方便的让摄像机在 Cube和Sphere之间聚焦. public Transform _cube; // Use this for initialization void Sta
如果需要处理鼠标点击物体的情况, 可以当数据接触物体时,鼠标手势改变,然后点击后和NPC产生对话等: using UnityEngine; using System.Collections; public class example : MonoBehaviour { void OnMouseOver() { renderer.material.color -= , ) * Time.deltaTime; } }
using UnityEngine; using System.Collections.Generic; using UnityEngine.EventSystems; using UnityEngine.UI; public class ManualRoam { private static ManualRoam mouse_this; public static ManualRoam Instance() { if (mouse_this == null) { mouse_this = ne
Primitive and Placeholder Objects 原始的基础物体 Unity can work with 3D models of any shape that can be created with modelling software. However, there are also a number of primitive object types that can be created directly within Unity, namely the Cube, S
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class CombineMesh : EditorWindow { [MenuItem("地图/合并Mesh")] static void AddWindow() { //创建窗口 CombineMesh window= (CombineMesh)EditorWindow.Ge
1,创建一根射线 2,检查射线与其他物体的碰撞,得到碰撞信息 3,通过碰撞信息对碰撞到的物体进行处理 using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { private Ray ray; private RaycastHit hit; void Update () { // 按鼠标左 if (
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Rotate : MonoBehaviour { private float origionZ; private Quaternion targetRotation; ; ; private bool i; // Use this for initialization void Start () { origion