
UGUI
tianyongheng
目前在做unity工作
展开
-
UGUI 将2DUI和场景中的3d物体关联,跟随物体移动
项目中经常会用到 UI 和场景的物体关联,之前的做法是将UI做成3D的,即将Canvas画布的属性 RenderMode 设置位WorldSpace。 但是这有一个缺点 摄像机移动或者摄像机缩放场景 ,导致UI字体会看不清。为了解决这个问题,就用到了游戏里的人物头顶血条。 主要的关键点是: 1.将3D物体的世界位置转换位屏幕坐标位置 Camera.main.WorldToScreenPoin原创 2018-01-23 10:46:13 · 3462 阅读 · 0 评论 -
Unity 向量转向 记录
unity 提供常用的旋转://从物体所在方向 转向目标所在的方向 主要是旋转物体Z轴 Quaternion.LookRotation(); //目标(target)所在的位置(方向,距离)即向量 减 自身(move)所在的位置 //所得向量差 v单位化,即到目标方向。 Vector3 vT = target.localPosition - move.localPosition;...原创 2018-05-23 17:12:04 · 3873 阅读 · 0 评论 -
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 · 1768 阅读 · 0 评论 -
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 · 743 阅读 · 0 评论 -
unity 物体转到目标点
public Quaternion GetLookAt(Vector3 ori, Vector3 targetPoint) { Vector3 dir = targetPoint - ori; Quaternion lookAtRot = Quaternion.LookRotation(dir); return...原创 2018-04-28 18:57:20 · 2854 阅读 · 0 评论 -
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 阅读 · 0 评论 -
unity 无限循环列表
具体下载地址不记得了,以下是网上代码贴出 三个 类 UILoopList , UILoopItem , UILoopListEzample using UnityEngine;using System.Collections;using System.Collections.Generic;public class UILoopListEzample : MonoBehavi...转载 2018-04-09 15:19:31 · 4276 阅读 · 1 评论 -
unity 屏蔽UGUI UI 穿透
unity 屏蔽UI 穿透的方法 if (EventSystem.current.IsPointerOverGameObject())//点击到UI上 { //屏蔽UI 渗透场景下层 //TODO:Doing... }原创 2018-01-18 14:35:35 · 2412 阅读 · 0 评论 -
鼠标移入屏蔽穿透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 · 941 阅读 · 0 评论 -
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 · 14134 阅读 · 0 评论