- 博客(53)
- 资源 (22)
- 收藏
- 关注
原创 unity删除丢失的脚本
unity 删除丢失的脚本 public static void DestoryMissScript() { if(Selection.activeGameObject==null) { return; } var gos = Selection.activeGameObject.GetComponentsInChildren<Transform>(true); foreach (v
2020-08-20 10:45:34
1722
2
原创 unity记录笔发射线 拉远拉近 方向
private Vector3 penPos ,hoverDis ;//GlobeData._RightRaycaster.BreakPoints[1] 射线笔检测到物体的射线碰撞点private void onRightRightPressDown(){ //记录射线笔的端点 即笔头 作为拉远、拉近基准点 penPos = GlobeData._RightRaycast...
2020-04-14 15:45:21
252
原创 unity鼠标滑动滚轮模型缩放
模型缩放private Update(){ int dir = 1; if (Input.GetAxis("Mouse ScrollWheel") > 0) { dir = 1; } else if (Input.GetAxis("Mouse ScrollWheel") < 0) ...
2020-04-14 15:04:00
1894
1
原创 unity 拖拽模型360旋转
模型360旋转//全局类 定义静态变量Tranform : _DragObGlobeData._DragOb ;private Update(){//鼠标按下记录按下的物体 if (Input.GetMouseButtonDown(1)) { GlobeData._DragObj = transform; ...
2020-04-14 15:00:27
1145
原创 Unity模型拖拽移动
unity 鼠标滑动屏幕根据滑动偏移量拖拽模型按下记录鼠标初始化位置private Vector3 lastpos;private float speed=10; private void OnMouseDown() { if (PlateformData.GetCurrentPlatform() == PlatformType.PC) { ...
2020-04-14 14:54:52
1916
原创 计算曲线
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;public class CusCurve { /// <summary> /// 获取曲线 计算多少个点,组成线 /// </summary> /// ...
2018-07-13 17:53:58
705
1
原创 unity canvas 屏幕自适应
untiy 屏幕自适应,一般根据固定宽或高进行适配 1.UI屏幕自适配 UI Scale Mode 设置为Scale With Screen Size; 注意 Math 设置需要根据实际需要 分情况而定 比如横屏:屏幕高度确定是1080,宽不确定,可能是双排,这是屏幕适配 with=0,界面设置 比如竖屏 屏幕宽度确定比如800,高度不确定,这时屏幕适配hight=1, 2.R...
2018-06-01 15:40:31
14103
原创 Unity 向量转向 记录
unity 提供常用的旋转://从物体所在方向 转向目标所在的方向 主要是旋转物体Z轴 Quaternion.LookRotation(); //目标(target)所在的位置(方向,距离)即向量 减 自身(move)所在的位置 //所得向量差 v单位化,即到目标方向。 Vector3 vT = target.localPosition - move.localPosition;...
2018-05-23 17:12:04
3862
原创 unity ugui 画曲线 跟随目标点缩放旋转 曲线终点和目标点保持一致
unity 画曲线 两种方式 一是生成点,由点组成线,比较消耗内存 二是用曲线图片方式解决 采用第二种: 1.新建 Panel 锚点拉伸全屏 2.新建Panel 命名为note锚点设置中心 width =0;height=0; 3.新建Panel 命名为lineRoot 锚点设置为中心 width =0;height=0; 4.在lineRoot 下新建image 锚点设置...
2018-05-15 18:54:38
1766
原创 地图坐标2D映射3D地图场景中
1.采集数据的地图mapData(名称),地图 长、宽: L,W 2.unity 需要一张地图map(名称) 长、宽:L/N,W/N (N 是缩放系数,和数据采集的地图保持比例 不能压缩变形)unity 中的地图是3D模型 还是是2D平面 分两种情况处理3D模型: 1. unity 中新建Canvas 2. 在3DMapCanvas下新建Panel命名为mapPanle 将m...
2018-05-15 11:54:53
3978
原创 UI曲线跟着目标点 旋转,拉伸缩放
//1. lineRoot是线的跟节点,所有的点组成线//2 lineRoot起点的坐标(lineRoot的位置==起点 条件是lineRoot中心重合)=sart//3.lineRoot终点= lineEndPoint//4.listLine是所有点集合 private void ComputeZoom() { float zoomFactor = V...
2018-05-14 19:01:55
740
原创 unity 随机获取圆内点
//半径随机 ,弧度随机 public Vector2 GetCirclePoint(int m_Radius) { //随机获取弧度 float radin = (float)GetRandomValue(0, 2 * Mathf.PI); float x = m_Radius * Mathf.Cos(radin); float ...
2018-05-14 18:03:23
4999
1
原创 unity 生成圆形 方法
using UnityEngine;using System;using System.Collections.Generic;public class DrawCircle : MonoBehaviour{ public Transform cub; public Transform m_Transform; public float m_Radius = 1;...
2018-05-14 17:33:38
8563
原创 Unity随机生成值
System.Random random;random = new System.Random(1000);public int RandomRange(int min, int max){ return random.Next(min, max);}public float RandomRange(float min, float max){ var r = ran...
2018-05-14 11:43:06
3024
原创 unity 物体转到目标点
public Quaternion GetLookAt(Vector3 ori, Vector3 targetPoint) { Vector3 dir = targetPoint - ori; Quaternion lookAtRot = Quaternion.LookRotation(dir); return...
2018-04-28 18:57:20
2843
原创 CSTween
CSTween 主要类: 1.CTweenData 处理移动数据 2.CTweenWithSame 处理伴随运动 3.CTween 4.CSPathAnimation 运动路径 5.WithSame伴随 6.ExtendCustomTween 扩展类 Transfrom,CTween 具体代码下载路径 https://download.youkuaiyun.com/download/ti...
2018-04-28 18:19:49
167
转载 unity 无限循环列表
具体下载地址不记得了,以下是网上代码贴出 三个 类 UILoopList , UILoopItem , UILoopListEzample using UnityEngine;using System.Collections;using System.Collections.Generic;public class UILoopListEzample : MonoBehavi...
2018-04-09 15:19:31
4271
原创 unity 异步加载图片2
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;public class ImgPackage{ /// <summary> /// 下载地址 /// </summary> public string u...
2018-04-09 14:28:42
1450
1
原创 窗体弹窗层级管理
using System.Collections;using System.Collections.Generic;using UnityEngine;using System;public class UIWindowPop : MonoBehaviour{ private static UIWindowPop _instance; public static UI...
2018-04-04 18:28:54
1074
原创 unity遍历查找孩子节点
protected Transform DeepFindChild(Transform root, string childName) { Transform result = null; result = root.Find(childName); if (result == null) ...
2018-03-06 14:35:19
2731
原创 多线程下载
简单得 使用线程池,和WebClient 结合下载资源到本地using System;using System.Collections;using System.Collections.Generic;using System.Diagnostics;using System.Net;using System.Text;using System.Threading;using U...
2018-02-28 14:29:28
383
翻译 unity 内嵌网页
写在前面 注意事项: 1.刷新网页时 ,如果网页和unity 有交互,不要用 browser.Reload() 用下面两行代码,而且顺序不能写反browser.LoadURL("地址", true);browser.RegisterFunction("Func", JSCallback);unity 内嵌网页 插件Embedded Browser 可与unity互相调用 下载...
2018-02-07 15:52:45
7263
原创 鼠标移入屏蔽穿透UI
using UnityEngine;using System.Collections;using System.Collections.Generic;using UnityEngine.UI;using UnityEngine.EventSystems;public class ShieldUIOver{ public static ShieldUIOver Instan
2018-01-25 10:25:42
938
原创 UGUI 将2DUI和场景中的3d物体关联,跟随物体移动
项目中经常会用到 UI 和场景的物体关联,之前的做法是将UI做成3D的,即将Canvas画布的属性 RenderMode 设置位WorldSpace。 但是这有一个缺点 摄像机移动或者摄像机缩放场景 ,导致UI字体会看不清。为了解决这个问题,就用到了游戏里的人物头顶血条。 主要的关键点是: 1.将3D物体的世界位置转换位屏幕坐标位置 Camera.main.WorldToScreenPoin
2018-01-23 10:46:13
3451
原创 unity 滚动 UI Scroll Rect
1.新建Canvas 2.新建Panel,命名为ViewScroll,设置宽高,即 可视滚动区域。 3.在ViewScroll 面板添加ScrollRect 组件用于滑动,添加 Mask 组件用于遮罩 4.在ViewScroll下新建 Panel 名为Content,Content面板的大小一定要超过ViewScroll的大小,才能滑动 5.将ScrollRect 的Content 设
2018-01-18 15:12:29
858
原创 unity 屏蔽UGUI UI 穿透
unity 屏蔽UI 穿透的方法 if (EventSystem.current.IsPointerOverGameObject())//点击到UI上 { //屏蔽UI 渗透场景下层 //TODO:Doing... }
2018-01-18 14:35:35
2407
原创 unity www 下载进度
IEnumerator LoadImg() { using (WWW www = new WWW(url)) { while(!www.isDone) { Debug.Log(www.progress); yield return null;
2018-01-11 10:30:17
1693
原创 unity 解析json 中的一些坑
目前接触的unity 解析json 有几种: 1.比较流行的listjson(数据对象必须和json一对一) 2.目前unity自带 JsonUtility(不能解析复杂的json) 3.Newtonsoft.Json (推荐可以解析复杂的json,不需要和json字段一对一 ,灵活) (下载地址:https://github.com/SaladLab/Json.Net.Unity3D/
2018-01-11 10:28:40
7519
原创 unity 常用的几种解析json方式
目前接触的unity 解析json 有几种: 1.比较流行的listjson(数据对象必须和json一对一) 2.目前unity自带 JsonUtility(不能解析复杂的json) 3.Newtonsoft.Json (推荐可以解析复杂的json,不需要和json字段一对一 ,灵活) (下载地址:https://github.com/SaladLab/Json.Net.Unity3D/
2018-01-06 16:16:48
40365
原创 unity csv 文件读取 工具封装
这套封装可以通过读取不同的csv文件,根据不同的枚举类型获取对应的数据using SevenG;using System;using System.Collections;using System.Collections.Generic;using System.IO;using UnityEngine;#region CSV解析的数据model/// /// EChart
2018-01-05 16:57:40
1320
原创 uniyt http 异步获取数据
HttpAsyn**重点内容** 下载采用协同,固定更新 每次从下载队列中取一个下载包 下载完成 通过下载包回调通知数据关心者HttpPackage**重点内容** 下载包 包含 回调 方法,http请求url对下载的数据 用jeson 解析,通过定义对应的数据对象,用JsonMapper 取转换,注意定义的数据对象一定要和jeson内容对应using System.Collec
2018-01-05 15:07:41
711
原创 unity shader 流水效果
改变uv 坐标值,去掉白色,透明Shader "Custom/UVOffset" { Properties{ _Color("Main Color", Color) = (1,1,1,1) _MainTex("Base (RGB) Trans (A)", 2D) = "white" {} _WhiteRange("WhiteRange",float)
2017-12-27 09:35:54
11447
原创 unity icon 面向相机
unity 场景中图标始终面向相机using System.Collections;using System.Collections.Generic;using UnityEngine;public class IconFollow : MonoBehaviour { //Quaternion direction; // Use this for initialization
2017-12-21 18:08:20
966
原创 unity画线
using System.Collections; using System.Collections.Generic; using UnityEngine;public class DrawWay:MonoBehaviour{ private LineRenderer line; private void Awake() { //OnDrawLine(new
2017-12-16 20:12:47
837
原创 unity 鼠标移动 缩放,旋转
2018-11-25修改:加入防止UI穿透,如果相机有PhysicsRaycaster组件,考虑检测到UI是否向下传递给3D物体 这时使用 EventSystem.current.IsPointerOverGameObject()的判断 不合适 2018-11-23修改:加入相机2D视角 和3D视角控制using System.Collections;using System.Coll
2017-12-16 20:09:42
444
原创 unity发布weblgl 接收 中文字体 报错
unity websocket 通信,接收服务器发来的数据还有中文要用uri编码 下面有utf-8编码试过不行,用uri 完全没问题public static string get_uft8(string unicodeString) { UTF8Encoding utf8 = new UTF8Encoding(); Byte[] e
2017-12-02 16:26:03
375
UMP2.0.3Pro.zip
2019-07-05
unity Line 虚线
2017-12-16
开启虚拟wifi
2013-03-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人