原创 unity記錄筆發射線 拉遠拉近 方向

private Vector3 penPos ,hoverDis ; //GlobeData._RightRaycaster.BreakPoints[1] 射線筆檢測到物體的射線碰撞點 private void onRightRi

原创 unity 解析json 中的一些坑

目前接觸的unity 解析json 有幾種: 1.比較流行的listjson(數據對象必須和json一對一) 2.目前unity自帶 JsonUtility(不能解析複雜的json) 3.Newtonsoft.Json (推

原创 Unity模型拖拽移動

unity 鼠標滑動屏幕根據滑動偏移量拖拽模型 按下記錄鼠標初始化位置 private Vector3 lastpos; private float speed=10; private void OnMouseDown()

原创 uniyt http 異步獲取數據

HttpAsyn**重點內容** 下載採用協同,固定更新 每次從下載隊列中取一個下載包 下載完成 通過下載包回調通知數據關心者 HttpPackage**重點內容** 下載包 包含 回調 方法,http請求url 對下載的數

原创 unity www 下載進度

IEnumerator LoadImg() { using (WWW www = new WWW(url)) { while(!www.isDone)

原创 UGUI 將2DUI和場景中的3d物體關聯,跟隨物體移動

項目中經常會用到 UI 和場景的物體關聯,之前的做法是將UI做成3D的,即將Canvas畫布的屬性 RenderMode 設置位WorldSpace。 但是這有一個缺點 攝像機移動或者攝像機縮放場景 ,導致UI字體會看不清。爲了

原创 unity 拖拽模型360旋轉

模型360旋轉 //全局類 定義靜態變量Tranform : _DragOb GlobeData._DragOb ; private Update() { //鼠標按下記錄按下的物體 if (Input.GetMous

原创 unity鼠標滑動滾輪模型縮放

模型縮放 private float minScale=0.5f; private float maxScale=3f; private Update() { int dir = 1; if (Input.G

原创 unity jeson 解析技巧

接手一項目實時數據傳輸協議用的jeson,個人覺得jeson協議使用就是方便,然後 jeson數據序列二進制後比較谷歌protobuf要大一半左右。 之前和同事聊天時protobuf 對可變長類型字節壓縮 對於 int32

原创 unity 屏蔽UGUI UI 穿透

unity 屏蔽UI 穿透的方法 if (EventSystem.current.IsPointerOverGameObject())//點擊到UI上 { //屏蔽UI 滲透場景下層

原创 unity發佈weblgl 接收 中文字體 報錯

unity websocket 通信,接收服務器發來的數據還有中文要用uri編碼 下面有utf-8編碼試過不行,用uri 完全沒問題 public static string get_uft8(string unicodeStr

原创 unity 計時管理

using UnityEngine; using System; using System.Collections; using System.Collections.Generic; public class TimerMan

原创 Unity UGUI 自適應

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class

原创 unity畫線

資源下載鏈接 http://download.csdn.net/download/tianyongheng/10161640 using System.Collections; using System.Collections.G

原创 unity shader 流水效果

改變uv 座標值,去掉白色,透明 Shader "Custom/UVOffset" { Properties{ _Color("Main Color", Color) = (1,1,1,1)