位置: 编程技术 - 正文
推荐整理分享小地图的实现与远近景的切换(小地图的主要作用是观察队友的大概位置),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:小地图的实现与运用,小地图是什么意思,小地图的实现与设计,什么是小地图,小地图绘制,小地图的主要作用,小地图的实现与运用,小地图的实现与实践,内容如对您有帮助,希望把文章链接给更多的朋友!
/// <summary>/// Minimap./// This script use to call minimap on top-right screen/// </summary>using UnityEngine;using System.Collections;public class Minimap : MonoBehaviour {private Vector2 defaultScreenRes; //Screen Resolution[System.Serializable]public class GUISetting{public Vector2 position;public Vector2 size;public Texture2D[] texture;}[System.Serializable]public class LabelSetting{public Vector2 position;public GUIStyle labelStyle;}[System.Serializable]public class MinimapSetting{public Vector2 position;public Vector2 size;public Texture texture;public Material renderMaterial;}[System.Serializable]public class ButtonSetting{public Vector2 position;public Vector2 size;public GUIStyle buttonStlye;}public GUISetting frameMap,mapNameBar; //GUI settingpublic MinimapSetting minimap; //Minimap settingpublic LabelSetting mapName; //Map name setting//引用 ButtonSetting 类,所有的图标都在 ButtonSetting里实实例化,在这个类里加载到界面;public ButtonSetting zoomInBt,zoomOutBt; //button setting// Use this for initializationvoid Start () {defaultScreenRes.x = ; //declare max screen ratiodefaultScreenRes.y = ; //declare max screen ratio}void OnGUI (){if(!GameSetting.Instance.hideMinimap){// Resize GUI Matrix according to screen size ResizeGUIMatrix();//Draw MinimapGraphics.DrawTexture(new Rect(minimap.position.x,minimap.position.y,minimap.size.x ,minimap.size.y),minimap.texture,minimap.renderMaterial);//Draw MinimapFrameGUI.DrawTexture(new Rect(frameMap.position.x,frameMap.position.y,frameMap.size.x,frameMap.size.y),frameMap.texture[0]);//Draw Map name barGUI.DrawTexture(new Rect(mapNameBar.position.x,mapNameBar.position.y,mapNameBar.size.x,mapNameBar.size.y),mapNameBar.texture[0]);TextFilter.DrawOutline(new Rect(mapName.position.x ,mapName.position.y, , ),Application.loadedLevelName,mapName.labelStyle,Color.black,Color.white,2f);//Draw zoom in button//GUI.Button():Make a single press button. The user clicks them and something happens immediately.if(GUI.Button(new Rect(zoomInBt.position.x,zoomInBt.position.y,zoomInBt.size.x,zoomInBt.size.y),"",zoomInBt.buttonStlye)){MinimapCamera.zoomLevel;MinimapCamera.Instance.ZoomUpdate();}//Draw zoom out buttonif(GUI.Button(new Rect(zoomOutBt.position.x,zoomOutBt.position.y,zoomOutBt.size.x,zoomOutBt.size.y),"",zoomOutBt.buttonStlye)){ //zoomLevel 减小,小地图视角要缩小;MinimapCamera.zoomLevel--;MinimapCamera.Instance.ZoomUpdate();}// Reset matrix after finish GUI.matrix = Matrix4x4.identity;}else{this.enabled = false;}}void ResizeGUIMatrix() { // Set matrix Vector2 ratio = new Vector2(Screen.width/defaultScreenRes.x , Screen.height/defaultScreenRes.y ); Matrix4x4 guiMatrix = Matrix4x4.identity; guiMatrix.SetTRS(new Vector3(1, 1, 1), Quaternion.identity, new Vector3(ratio.x, ratio.y, 1)); GUI.matrix = guiMatrix; }}
【unity资源管理】内存池 内存池思想:创建对象时,先检查内存池中是否有缓存对象,如果没有再创建新的。删除对象时,不立即销毁,缓存一段时间,避免重复创建,提升执
编辑器拓展 Menuitem usingUnityEngine;usingSystem.Collections;usingUnityEditor;publicclassMyEditorWindow:EditorWindow{[MenuItem(Window/MyWindow)]staticvoidAddWindow(){//创建窗口Rectrect=newRect(0,0,,);MyEditorWi
编辑器拓展 CustomEditor usingUnityEngine;usingSystem.Collections;usingUnityEditor;//自定义样式的脚本[CustomEditor(typeof(CubeScript))]publicclassEditorTest:Editor{//自定义Inspector视图publicoverridevoidOnInspect
友情链接: 武汉网站建设