赞
踩
using UnityEngine; using System.Collections; public class Minimap : MonoBehaviour { public Camera minimapCamera; public float minfiledView = 44f; public float maxfiledView = 95f; private Vector3 offsetPosition; void Start () { } // Update is called once per frame void Update () { } public void ZoomInButtonClick() { if (minimapCamera.fieldOfView > minfiledView) { minimapCamera.fieldOfView -= 1; } else minimapCamera.fieldOfView = minfiledView; } public void ZoomOutButtonClick() { if (minimapCamera.fieldOfView < maxfiledView) { minimapCamera.fieldOfView += 1; } else minimapCamera.fieldOfView = maxfiledView; } }此处的代码构思来源于小地图的制作,通过控制fieldOfView来确定Camera的视野大小,大家也可以设定视野的范围,让他在指定区间内变化。
using UnityEngine; using System.Collections; using System.IO; using System; using System.Drawing; public class OpenPicture : MonoBehaviour { public Texture2D _texture; public GameObject DaYangTu; IEnumerator Open() { string path = Application.persistentDataPath + "/Image" + "/placeholder.jpg"; WWW www = new WWW("file://" + path); yield return www; Debug.Log(":" + www.error); _texture = new Texture2D(300, 300); _texture = www.texture; DaYangTu.GetComponent<UITexture>().mainTexture = _texture; } public void OnClick() { DaYangTu.SetActive(true); StartCoroutine(Open()); } // Update is called once per frame void Update () { } }此处我使用的是使用WWW加载本地指定路径的文件,发布后可以更换图片,但名字要保持不变。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。