中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

線上店免費(fèi)推廣的軟件廊坊seo排名霸屏

線上店免費(fèi)推廣的軟件,廊坊seo排名霸屏,智能建造的發(fā)展趨勢,濟(jì)南地鐵建設(shè)1. 用于將世界坐標(biāo)系轉(zhuǎn)換為屏幕坐標(biāo)系 using System.Collections; using System.Collections.Generic; using UnityEngine;public class Camer_Class_WorldTo : MonoBehaviour {// 用于將世界坐標(biāo)系轉(zhuǎn)換為屏幕坐標(biāo)系//本腳本將完成一個(gè)案例實(shí)現(xiàn) 小球從遠(yuǎn)處過來Transform Sta…

1.? 用于將世界坐標(biāo)系轉(zhuǎn)換為屏幕坐標(biāo)系?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Camer_Class_WorldTo : MonoBehaviour
{// 用于將世界坐標(biāo)系轉(zhuǎn)換為屏幕坐標(biāo)系//本腳本將完成一個(gè)案例實(shí)現(xiàn) 小球從遠(yuǎn)處過來Transform StarFather;Transform StarChild;Vector3 ScreenPoint;Vector3 ViewPoint;Camera OneCamera;void Start(){StarFather = GameObject.FindGameObjectWithTag("Earth").transform;OneCamera = Camera.main;//獲取主攝像機(jī)}// Update is called once per framevoid Update(){ScreenPoint = OneCamera.WorldToScreenPoint(StarFather.GetChild(0).transform.position);//世界坐標(biāo)轉(zhuǎn)換 屏幕坐標(biāo)StarFather.GetChild(0).transform.RotateAround(StarFather.transform.position, Vector3.up, 50 * Time.deltaTime);ClickDestory();//實(shí)現(xiàn)小球轉(zhuǎn)后的屏幕坐標(biāo)系和鼠標(biāo)點(diǎn)擊的坐標(biāo)匹配然后刪除該物體ViewPoint = OneCamera.WorldToViewportPoint(StarFather.GetChild(0).transform.position);//世界坐標(biāo)轉(zhuǎn)換 攝像機(jī)視口坐標(biāo)}private void OnGUI(){GUILayout.BeginArea(new Rect(50, 20, 500, 300));GUILayout.Label("小球的原始坐標(biāo):" + (StarFather.GetChild(0).transform.position));GUILayout.Label("世界坐標(biāo)轉(zhuǎn)換 屏幕坐標(biāo)后" + ScreenPoint);GUILayout.Label("鼠標(biāo)屏幕坐標(biāo)" + Input.mousePosition);GUILayout.Label(("世界坐標(biāo)轉(zhuǎn)換 視口坐標(biāo)后" + ViewPoint));GUILayout.EndArea();}void ClickDestory(){Vector2 TempTurnScreen = new Vector2(ScreenPoint.x, ScreenPoint.y);Vector2 TempMousePoint = new Vector2(Input.mousePosition.x, (Input.mousePosition.y));Vector3 Lerp = TempTurnScreen - TempMousePoint;if (Lerp.magnitude < 20 & Lerp.magnitude > 0){Debug.Log("鼠標(biāo)碰撞物體成功!!!!!!!!!!!!!!!!!");if (Input.GetMouseButtonDown(0)){Destroy(StarFather.GetChild(0).gameObject);}Debug.Log("死亡位置!!!!" + ScreenPoint);}}}

2.?屏幕坐標(biāo)轉(zhuǎn)化為視口坐標(biāo) Camera.ScreenToViewportPoint和?屏幕轉(zhuǎn)世界坐標(biāo) ? ?

本案例實(shí)現(xiàn) 屏幕鼠標(biāo)移動(dòng)轉(zhuǎn)換為視口和屏幕轉(zhuǎn)世界坐標(biāo)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Camera_Class : MonoBehaviour
{// 用于測試Camera 類 坐標(biāo)系轉(zhuǎn)換//1. 屏幕坐標(biāo)轉(zhuǎn)化為視口坐標(biāo) Camera.ScreenToViewportPoint 本案例實(shí)現(xiàn) 屏幕鼠標(biāo)移動(dòng)轉(zhuǎn)換為視口// 2.屏幕轉(zhuǎn)世界坐標(biāo)      public float Speed = 100f;Vector3 Temppos_Worlspos;//接收屏幕轉(zhuǎn)換后的世界坐標(biāo)Vector2 mousePos = new Vector2();//接收獲取到的屏幕坐標(biāo)系2DVector3 Turn_View_Point = new Vector3();//接收轉(zhuǎn)化后的視口坐標(biāo)bool ISrotate = false;bool IsCreatSphere = false;private Camera cam;void Start(){float starTime = Time.time;cam = Camera.main;//如果想要使用主相機(jī) 就可以使用此方法直接獲取主相機(jī), 我們這里主要使用主攝像機(jī)進(jìn)行坐標(biāo)系轉(zhuǎn)換測試}private void Update(){mousePos = Input.mousePosition;//獲取屏幕鼠標(biāo)移動(dòng)坐標(biāo)值Turn_View_Point = cam.ScreenToViewportPoint(new Vector3(mousePos.x, mousePos.y, 100f));//屏幕轉(zhuǎn)視口坐標(biāo)系 100是自定義數(shù)值//_________________________________________________________________________________________________________________Temppos_Worlspos = cam.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, 100f));//屏幕轉(zhuǎn)世界坐標(biāo)      //_________________________________________________________________________________________________________________//Move(Temppos_Worlspos);Create_Obj_inScreenTurnWorld_Pos(Temppos_Worlspos);//實(shí)現(xiàn)屏幕鼠標(biāo)點(diǎn)擊轉(zhuǎn)換世界坐標(biāo)系然后在這個(gè)位置克隆小球}void OnGUI()//在UNITY的聲明周期中,OnGUI是在Update后面運(yùn)行,每幀運(yùn)行兩次 用于輸出信息{GUILayout.BeginArea(new Rect(20, 50, 500, 300));//創(chuàng)建一塊UI顯示區(qū)域, 標(biāo)簽框GUILayout.Label("獲取到的屏幕鼠標(biāo)坐標(biāo)Mouse position: " + mousePos);GUILayout.Label("給100f的Z值,屏幕坐標(biāo)轉(zhuǎn)換成View視口坐標(biāo)后為:" + Turn_View_Point);GUILayout.Label("————————————————————————————————————");GUILayout.Label("當(dāng)前攝像機(jī)的Z坐標(biāo):" + cam.transform.position.z + "轉(zhuǎn)換世界坐標(biāo)后World position: " + Temppos_Worlspos);GUILayout.EndArea();//結(jié)束UI顯示區(qū)域, 標(biāo)簽框}void Create_Obj_inScreenTurnWorld_Pos(Vector3 Temppos_Worlspos)//實(shí)現(xiàn)屏幕鼠標(biāo)點(diǎn)擊轉(zhuǎn)換世界坐標(biāo)系然后在這個(gè)位置克隆小球{if (Input.GetMouseButtonDown(0)){IsCreatSphere = true;do{if (IsCreatSphere){GameObject FatherPlayer = GameObject.FindGameObjectWithTag("Player");GameObject TempSphereclone = GameObject.CreatePrimitive(PrimitiveType.Sphere);TempSphereclone.transform.SetParent(FatherPlayer.transform);//設(shè)置父物體TempSphereclone.GetComponent<Renderer>().material.color = Color.yellow;//設(shè)置顏色TempSphereclone.transform.position = Temppos_Worlspos;//設(shè)置坐標(biāo)TempSphereclone.transform.localScale = new Vector3(8, 8, 8);//設(shè)置縮放IsCreatSphere = false;Destroy(TempSphereclone, 1f);}} while (false);}}void Move(Vector3 TempV3)//點(diǎn)擊右鍵 移動(dòng){//插值平滑運(yùn)動(dòng)//Vector3 Temp =Vector3.Lerp(transform.position, TempV3, (Time.time- starTime)*Speed);//插值平滑運(yùn)算 (起點(diǎn), 終點(diǎn),起點(diǎn)靠近終點(diǎn)的比例)//  this.transform.position = Vector3.Lerp(transform.position, TempV3, (Time.time - starTime) * Speed);//  Debug.Log((Time.time - starTime) * Speed +"sudu"+ Temp);//  //普通運(yùn)動(dòng)Vector3 Dir = Temppos_Worlspos - transform.position;this.transform.Translate(Dir.normalized * 20 * Time.deltaTime);}
}

? ?3.視口轉(zhuǎn)世界坐標(biāo)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Camera_Class_Two : MonoBehaviour {// 本腳本用于測試 坐標(biāo)系轉(zhuǎn)換Camera OneCam;Vector3 ViewToWorld;Vector3 ViewToScreen;void Start (){OneCam = Camera.main;//這個(gè)可以快速獲取標(biāo)簽為MainCamera 的攝像機(jī)OneCam.transform.position = new Vector3(0,0,-20f);//相機(jī)初始化位置Debug.Log("視口坐標(biāo)(0,0,100)轉(zhuǎn)世界坐標(biāo)系" + OneCam.ViewportToWorldPoint(new Vector3(0, 0, 100f)));//轉(zhuǎn)之后的Z坐標(biāo)是攝像機(jī)原Z坐標(biāo)加上賦值的Z值Debug.Log("視口坐標(biāo)(0.5,0.5,100)轉(zhuǎn)世界坐標(biāo)系" + OneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 100f)));//轉(zhuǎn)之后的Z坐標(biāo)是攝像機(jī)原Z坐標(biāo)加上賦值的Z值Debug.Log("視口坐標(biāo)(1,1,100)轉(zhuǎn)世界坐標(biāo)系" + OneCam.ViewportToWorldPoint(new Vector3(1, 1, 100f)));//轉(zhuǎn)之后的Z坐標(biāo)是攝像機(jī)原Z坐標(biāo)加上賦值的Z值Debug.Log("————————下面是視口轉(zhuǎn)屏幕————————————————————————" );Debug.Log("視口坐標(biāo)(0,0,100f)轉(zhuǎn)屏幕坐標(biāo)系" + OneCam.ViewportToScreenPoint(new Vector3(0, 0, 100f)));Debug.Log("視口坐標(biāo)(0,0,100f)轉(zhuǎn)屏幕坐標(biāo)系" + OneCam.ViewportToScreenPoint(new Vector3(0.5f, 0.5f, 100f)));Debug.Log("視口坐標(biāo)(0,0,100f)轉(zhuǎn)屏幕坐標(biāo)系" + OneCam.ViewportToScreenPoint(new Vector3(1f, 1f, 100f)));//————————————————————————————世界轉(zhuǎn)視口和平面————————————————}private void OnGUI(){GUILayout.BeginArea(new Rect(50, 20, 800,300));GUILayout.Label("視口坐標(biāo)(0,0,100)     轉(zhuǎn)【世界】坐標(biāo)系" + OneCam.ViewportToWorldPoint(new Vector3(0, 0, 100f))+"Z 等于攝像機(jī)坐標(biāo)+賦值的Z");GUILayout.Label("視口坐標(biāo)(0.5,0.5,100)轉(zhuǎn)【世界】坐標(biāo)系" + OneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 100f)));GUILayout.Label("視口坐標(biāo)(1,1,100)      轉(zhuǎn)【世界】坐標(biāo)系" + OneCam.ViewportToWorldPoint(new Vector3(1, 1, 100f)));GUILayout.Label("____________________________________________________________");GUILayout.Label("視口坐標(biāo)(0,0,100f)轉(zhuǎn)【屏幕】坐標(biāo)系" + OneCam.ViewportToScreenPoint(new Vector3(0, 0, 100f))+"Z值對屏幕坐標(biāo)系來說并沒有用");GUILayout.Label("視口坐標(biāo)(0,0,100f)轉(zhuǎn)【屏幕】坐標(biāo)系" + OneCam.ViewportToScreenPoint(new Vector3(0.5f, 0.5f, 100f)));GUILayout.Label("視口坐標(biāo)(0,0,100f)轉(zhuǎn)【屏幕】坐標(biāo)系" + OneCam.ViewportToScreenPoint(new Vector3(1f, 1f, 100f)));GUILayout.Label("____________________________________________________________");GUILayout.EndArea();//結(jié)束UI顯示區(qū)域, 標(biāo)簽框}
}

4.向屏幕中間或者視口中間發(fā)射射線

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Camera_Class_ScreenPointToRay : MonoBehaviour {Camera cam;Vector3 RayTargetPoint;Vector3 RayScreen_TargetPoint;void Start(){cam = GetComponent<Camera>();RayTargetPoint = new Vector3(0f,0.5f,0f);}void Update(){RayScreen_TargetPoint = Input.mousePosition;RayTargetPoint.x=RayTargetPoint.x >= 1.0f ? 0.0f : RayTargetPoint.x +0.02f;//數(shù)值增加Ray View_ray = cam.ViewportPointToRay(RayTargetPoint);//朝攝像機(jī)視口上的目標(biāo)點(diǎn)發(fā)射射線Ray Screen_ray = cam.ScreenPointToRay(RayScreen_TargetPoint);//朝向屏幕上某個(gè)點(diǎn)發(fā)射射線//Debug.Log("當(dāng)前射線目標(biāo)點(diǎn)在視口中的位置" + RayTargetPoint);Debug.DrawRay(View_ray.origin, View_ray.direction * 800, Color.yellow);//繪制射線Debug.DrawRay(Screen_ray.origin, Screen_ray.direction * 800, Color.red);//繪制射線RaycastHit hit;//反射探測到的物體if (Physics.Raycast(View_ray, out hit)){print("我看見了物體: " + hit.transform.name);}}
}

http://m.risenshineclean.com/news/62812.html

相關(guān)文章:

  • 佛山多語網(wǎng)站制作手游代理平臺哪個(gè)好
  • 鹽城網(wǎng)站建設(shè)培訓(xùn)班哈爾濱最新疫情
  • 舉報(bào)網(wǎng)站怎么做新手怎么做網(wǎng)絡(luò)銷售
  • 河北高端網(wǎng)站制作qq群排名優(yōu)化軟件購買
  • 圖文可以做網(wǎng)站設(shè)計(jì)嗎電商運(yùn)營推廣的方式和渠道有哪些
  • wordpress主題+插件深圳做seo有哪些公司
  • 深圳網(wǎng)站建設(shè)信科獨(dú)家友情鏈接外鏈
  • 外貿(mào)獨(dú)立站搭建東莞seo優(yōu)化推廣
  • 北京 網(wǎng)站 公安備案品牌推廣平臺
  • win7怎么做網(wǎng)站服務(wù)器嗎怎么優(yōu)化網(wǎng)站關(guān)鍵詞排名
  • 哪個(gè)公司網(wǎng)站做的好阿拉善盟seo
  • 真正學(xué)做網(wǎng)站要多久北京seo優(yōu)化排名
  • 網(wǎng)站開發(fā)視頻教學(xué)網(wǎng)絡(luò)優(yōu)化推廣公司哪家好
  • 什么專業(yè)學(xué)做網(wǎng)站seo黑帽培訓(xùn)騙局
  • 普陀做網(wǎng)站免費(fèi)手游推廣平臺
  • 廣州佛山建設(shè)信息網(wǎng)站個(gè)人微信管理系統(tǒng)
  • java網(wǎng)站開發(fā)通用框架seo優(yōu)化主要工作內(nèi)容
  • 網(wǎng)站建設(shè)seoppt百度關(guān)鍵詞優(yōu)化多少錢一年
  • 國外免費(fèi)b2b網(wǎng)站排名互聯(lián)網(wǎng)營銷策略有哪些
  • wordpress 調(diào)用 apigoogleseo優(yōu)化
  • 網(wǎng)站模板與網(wǎng)站開發(fā)電商軟文范例300字
  • 只用ip做網(wǎng)站 不備案市場營銷活動(dòng)策劃方案
  • 繼電器做網(wǎng)站關(guān)鍵詞排名監(jiān)控
  • 外貿(mào)開發(fā)產(chǎn)品網(wǎng)站建設(shè)時(shí)空seo助手
  • 網(wǎng)站建設(shè)運(yùn)營知乎淮安百度推廣公司
  • 網(wǎng)站建設(shè)注意企業(yè)網(wǎng)站設(shè)計(jì)代碼
  • 朝陽做網(wǎng)站的公司杭州百度整站優(yōu)化服務(wù)
  • 石家莊網(wǎng)站建站公司百度廣告位價(jià)格
  • 怎樣下載網(wǎng)頁上的視頻如何將網(wǎng)站的關(guān)鍵詞排名優(yōu)化
  • 做網(wǎng)站的書籍推薦網(wǎng)絡(luò)小說網(wǎng)站三巨頭