- 博客(61)
- 收藏
- 关注
转载 Unity学习链接
https://zhuanlan.zhihu.com/p/274389461、优化UGUI的ScrollRect:http://qiankanglai.me/2015/08/15/LoopScrollRect/http://blog.csdn.net/dingxiaowei2013/article/details/707698922、Remove、Replace、S...
2017-09-27 09:04:00 127
转载 UGUI Text文字左右循环运动
using UnityEngine;using System.Collections;public class MoveTarget : MonoBehaviour{ public GameObject _target1;//左侧目标位置 public GameObject _target2;//右侧目标位置 bool _check = ...
2017-07-17 16:35:00 297
转载 3d物体平缓摆动
transform.position = Vector3.Lerp(start.transform.position, end.transform.position, Mathf.SmoothStep(0f, 1f, Mathf.PingPong(Time.time / 3f, 1f))); 转载于:https://www.cnblogs.com/Cocomo/p/...
2017-07-13 15:15:00 160
转载 【转】unity www读取本地视频文件和外部视频文件 播放视频动画和视频声音
using System.Runtime.InteropServices;using UnityEngine;using System.Collections;using Assets;public class PlayVideo : MonoBehaviour{ public string url; public MovieTexture...
2017-06-30 09:12:00 602
转载 改变图片或文字颜色( Gradient)
using UnityEngine;using System.Collections;using System.Collections.Generic;using UnityEngine.UI;[AddComponentMenu("UI/Effects/Gradient")]public class Gradient : BaseVertexEffect {...
2017-06-28 08:41:00 162
转载 改变图片透明度
///模型从不透明变成透明直至消失using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class TestClass : MonoBehaviour{ private float tempTi...
2017-06-28 08:38:00 109
转载 Animation脚本
///***注:模型要设置类型为Legacy,否则动画不能播放//Unity制作的单个动画播放public class AnimationControl : MonoBehaviour {public Animation anim;public AnimationClip _anim;public Toggle BatteryTog;void Awake()...
2017-06-20 10:46:00 323
转载 实例化物体
public GameObject InstanceGameobject(string _path, Transform _parent) { GameObject obj = Resources.Load(_path, typeof(GameObject)) as GameObject; GameObject go = Instant...
2017-06-15 10:45:00 140
转载 unity 控制端调虚拟端
using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement; using System.Diagnostics; /// <summary> /// 脚本挂载在button上 /// 跨场景...
2017-05-17 16:49:00 96
转载 InputFiled中输入数值,text动态显示数值,当输入数值>text中数值,text中的数值动态递增;反之,动态递减。...
using UnityEngine;using System.Collections;using UnityEngine.UI;using System;/// <summary>/// 在输入框输入数字,在现实文本中数值动态增加,可多次输入/// InputFiled中输入数值,text动态显示数值,当输入数值>text中数值,text中的...
2017-05-16 16:08:00 136
转载 双屏通信发布注意要点
1:虚拟端发布出来要带着配置文件。2:控制端也应该带着配置文件,将虚拟端整体放入控制端的_Data文件夹下。3:注意文件名只能以英文命名。//“控制端调用虚拟端”脚本截图4:发布后,文件放置如下://虚拟端全部放在控制端的Boiling_Data文件夹中,如下图所示:转载于:https://www.cnblogs.com/Cocomo/p/663...
2017-03-29 09:43:00 90
转载 双屏通信
//二级旋钮public void TwoStateClick(GameObject game) { CheckState = !CheckState; if (CheckState == false) { //左转,默认状态 game.GetComponent<...
2017-03-02 14:07:00 94
转载 UGUI替换图片的三种方式
//方法一: Image/pic 在 Assets/Resources/目录下 Image _myImage; void Start(){ _myImage.sprite = Resources.Load("Image/pic", typeof(Sprite)) as Sprite;}//方法二:mySprite 为外部指定的图片资源Image ...
2017-02-28 10:14:00 201
转载 数据显示动态变化
public IEnumerator IData() { yield return null; while (true) { TemperatureData(45f, 50f); yield return new WaitFo...
2016-12-08 13:29:00 209
转载 随机数Random
using UnityEngine;using System.Collections;using UnityEngine.UI;using System.Collections.Generic;public class CircuitControl : MonoBehaviour{ public List<Image> RBsprites...
2016-12-07 13:18:00 101
转载 沿X轴移动
Mould.transform.localPosition = new Vector3(Mathf.MoveTowards(Mould.transform.localPosition.x, -30f, Time.deltaTime * 2f), Mould.transform.localPosition.y, Mould.transform.localPosition.z);...
2016-11-25 19:07:00 231
转载 (3D物体运动)开关控制3D朝着六个方向移动一定的距离
using UnityEngine;using System.Collections;using UnityEngine.UI;public class DirectionMove : MonoBehaviour { public GameObject WestMoveTog;//西移 public GameObject EastMoveTog...
2016-11-23 18:51:00 131
转载 单例模式
单例模式(也叫单件模式)的作用就是保证在整个应用程序的生命周期中,任何一个时刻,单例类的实例都只存在一个(当然也可以不存在)。单例模式脚本,非静态方法需要挂载,否则会报空;using UnityEngine;using System.Collections;public class Single : MonoBehaviour { // 定义...
2016-10-11 11:05:00 80
转载 多个按钮控制多个窗体
using UnityEngine;using System.Collections;using UnityEngine.UI;public class WinControl : MonoBehaviour { public GameObject WinBtn1; public GameObject WinBtn2; public GameO...
2016-09-22 09:44:00 137
转载 更换模型的材质(点击鼠标左右键)
using UnityEngine;using System.Collections;public class ChangeMatericals : MonoBehaviour { public Material IniMaterical;// 替换前材质(原材质) public Material ChangeMaterical;//替换后的材质(...
2016-09-14 08:48:00 142
转载 控制同一窗体的显隐(Toggle和Button)
公共变量的脚本using UnityEngine;using System.Collections;using UnityEngine.UI;public class CommonValues : MonoBehaviour { public GameObject AnswerShowWin;//答案显示窗口 public Button C...
2016-08-27 14:44:00 119
转载 Toggle控制窗口的显隐
public GameObject ToggleControl;//控制窗体显隐的开关private bool Flag; //用于获取Toggle的开关状态Public GameObject InforWin;//信息窗口void Start(){ InforWin.SetActive(false); EventTriggerListener.Get(To...
2016-08-24 17:30:00 134
转载 碰撞检测(2D&&3D)
共同点:发生碰撞的两个物体应满足的条件:NO1:两物体都应该有碰撞体NO2:其中一个带刚体;NO3:检测触发信息的脚本需绑定在带刚体的物体上不同点:2D碰撞检测加2D碰撞体和2D刚体;3D碰撞检测加3D碰撞体和3D刚体;3D碰撞检测:1.MonoBehaviour.OnCollisionEnter( Collision collisionInfo ) ...
2016-08-17 15:00:00 189
转载 3D空间 圆柱体画线
//添加一个圆柱体//添加多个Cube//切记:脚本不能绑定在圆柱体上,会因为不断调用自身而造成死循环。using UnityEngine;using System.Collections;public class StartDrawLine : MonoBehaviour{ public GameObject Line;//圆柱体用于画线条;...
2016-08-10 09:50:00 368
转载 鼠标拖动2D物体(图片)
using UnityEngine;using UnityEngine.EventSystems;using UnityEngine.UI;[RequireComponent(typeof(Image))]public class DragMe : MonoBehaviour, IBeginDragHandler, IDragHandler,IEndDragHan...
2016-08-09 15:20:00 109
转载 实现图片的闪烁效果
using UnityEngine;using System.Collections;using UnityEngine.UI;using System.Collections.Generic;public class TwinkleImg : MonoBehaviour{ private Image img; private float ...
2016-08-08 16:10:00 371
转载 UI 2D图片随鼠标旋转
//脚本挂在旋转的图片上,CubeZ的坐标设置为(0,0,1),要将轴心点放在中间位置using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.EventSystems;public class RotateIt : MonoBehaviour, IB...
2016-08-08 10:12:00 95
转载 射线检测(Summary)
1 1 //设置物体的Layer层级,在摄像机中设置camera.cullingmask,可以控制摄像机的渲染层级, 2 //用在射线上,可以控制射线碰撞什么,不碰撞什么。 3 2 4 3 //Raycast hit 5 4 RaycastHit hit; 6 5 LayerMask mask = 1 << 8; 7 6 void...
2016-08-03 16:23:00 82
转载 [转]C#静态方法与非静态方法的比较
转自:http://www.cnblogs.com/NothingIsImpossible/archive/2010/07/28/1786706.html1:C#的类中可以包含两种方法:C#静态方法与非静态方法。2:那么他们的定义有什么不同呢?他们在使用上会有什么不同呢?让我们来看看最直观的差别:使用了static 修饰符的方法为静态方法,反之则是非静态方法。3:下...
2016-08-03 09:05:00 102
转载 获取精灵
public Image BgImage;//从Inspector的文件夹中获取图片BgImage.sprite = Resources.Load("Pic02/Basic RecogniseWinPic/" + message, typeof(Sprite)) as Sprite; 转载于:https://www.cnblogs.com/Cocomo/...
2016-07-29 14:46:00 78
转载 用于切割字符串的方法
using UnityEngine;using System.Collections;using UnityEngine.UI;using System.Collections.Generic;public class ReadEditorInfo : MonoBehaviour{ //传值对象为字符串 string ContentInfo;//存储输入的文本内容 ...
2016-07-28 11:27:00 111
转载 获取Button的名字 并在按下时持续打印
//方法一:利用泛型集合 获取Button名字 实现持续打印using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.EventSystems;using System.Collections.Generic;public class PrintI...
2016-07-27 14:52:00 163
转载 LateUpdate、Late、FixedUpdate的意义
1、MonoBehaviour.Update 更新当MonoBehaviour启用时,其Update在每一帧被调用。2、MonoBehaviour.FixedUpdate 固定更新当MonoBehaviour启用时,其 FixedUpdate在每一帧被调用。处理Rigidbody时,需要用FixedUpdate代替Update。例如:给刚体加一个作用力时,你必须应用作用...
2016-07-25 19:01:00 282
转载 限定拖拽范围
//将脚本绑定在需要被限定范围的物体上using UnityEngine;using System.Collections;public class ControlLimited : MonoBehaviour{ float dis; //移动的最大距离 [SerializeField] private float MoveMaxDis...
2016-07-25 18:57:00 117
转载 物体移动到目标位置
MoveTowards: voidUpdate() { floatstep=speed*Time.deltaTime; gameObject.transform.localPosition=Vector3.MoveTowards(gameObject.transform.localPosition,new...
2016-07-20 18:03:00 103
转载 UI中心跟随鼠标移动
//脚本挂在需要跟随鼠标移动的UI上using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.EventSystems;public class CharacterControl : MonoBehaviour{ public Camera ...
2016-07-20 16:28:00 161
转载 拖动UI组件(坐标转换)
using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.EventSystems;public class MoveDirections : MonoBehaviour{ //控制四个方向的按钮 public GameObject MoveU...
2016-07-20 15:25:00 83
转载 切换视角(视角递增and递减)
//ViewChanged脚本需绑定在主相机上using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.EventSystems;public class ViewChanged : MonoBehaviour, IPointerClickHandler{ publ...
2016-07-16 10:18:00 82
转载 Unity快捷键
转自:http://blog.csdn.net/meegomeego/article/details/38439593一、近距离查看游戏对象 在Hierarchy视图中选择游戏对象,然后在Scene视图中按快捷键“F”来近距离查看该游戏对象。二、游戏对象不在主摄像头中? Hierarchy中双击选择需要显示的游戏对象,再单击Main Camera选中,最后Ctr...
2016-07-16 08:55:00 104
转载 获取碰撞物体的属性
public GameObject obj; void OnCollisionEnter(Collision col) { //获取当前碰撞到的物体 obj=col.gameObject; }转载于:https://www.cnblogs.com/Cocomo/p/5670158.html...
2016-07-14 13:43:00 397
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人