- 博客(62)
- 资源 (11)
- 收藏
- 关注
原创 unity运行中场景指定模型回放功能(模型是地形并且可以加载预制体进行回放)
必须标记为指定的标签(默认"DynamicObject")将TerrainRecorder添加到场景中的空对象。创建UI并连接TerrainRecorderUI脚本。将动态物体预制体放入Resources文件夹。预制体名称不能包含"(Clone)"建议使用简单的物体以保持性能。连接目标Terrain。
2025-04-02 15:31:40
192
原创 在C#中按空格分隔字符串
这里的StreamingAssetsReader.SandTableData.Values 是字典里面的value值 所以也是个string内容。
2025-03-31 16:16:59
151
原创 unity 截图并且展现在UI中
右键 Hierarchy → UI → RawImage(命名为 ScreenshotThumbnail)。latestScreenshotDisplay → 拖入一个 RawImage(用于显示最新截图)。screenshotListContainer → 拖入 ScrollView/Content。调整大小(如 200x200),并添加 Button 组件(方便点击查看大图)。右键 Hierarchy → UI → ScrollView。调整大小,确保能容纳多个缩略图。
2025-03-28 11:51:54
356
原创 unity 做一个圆形分比图
给 “MultiProgress” 对象添加 MultiCircleProgress 脚本。设置为 Filled 类型,Fill Method 为 Radial 360。在 Canvas 下创建空对象 “MultiProgress”创建 Image 对象,命名为 “SegmentPrefab”创建空对象 “TextContainer” 作为文本父对象。命名为 “PercentTextTemplate”创建 Text 对象,设置好字体样式。将预制体和文本模板拖拽到脚本对应字段。初始设置为非激活状态。
2025-03-27 17:00:17
359
原创 tcp局域网简单通讯
服务器端从streamingassets下读取图片或者视频需要插入插件UnityMainThreadDispatcher-master插件。// PlayVideo(“初始场景”);
2025-01-23 18:58:53
713
原创 unity 摄像机追随指定物体
unity 摄像机追随指定物体, 摄像机离远离近,围绕物体旋转using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.EventSystems;using UnityEngine.UI;public class CameraToTarget : MonoBehaviour {public Transform Camera2;public GameObject ob
2022-04-20 10:58:56
1610
1
原创 unity运行时保存预制物
预制物体在运行是给子级添加物体后进行保存,下次运行添加的物体依然存在using System.Collections;using System.Collections.Generic;using UnityEditor;using UnityEngine;public class savePrefab : MonoBehaviour{ // Update is called once per frame void Update() { if
2022-01-19 10:30:11
4111
3
原创 unity获取xml文件内容
我是将xml放在了unity Resources文件夹下,如图然后在xml写下你要获取指定物体得内容接下来就是脚本上如何获取了Dictionary<int, string> dicxml;public int dicindex = 0;XmlNodeList node;XmlDocument xmlDoc;//解析xmlvoid parseXml(){filePath = Application.dataPath + “/Resources/item.xml”;if (
2021-12-20 15:30:27
1860
原创 unity判断当前网络环境
if (Application.internetReachability == NetworkReachability.NotReachable) { Debug.Log("无网络"); } //当用户使用WiFi时 if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork).
2021-12-09 09:50:05
296
原创 unity粒子按照指定位置移动
using UnityEngine;using System.Collections;using System.Collections.Generic;public class TestParticleMovement : MonoBehaviour{ public List<Vector3> nodes; public Vector3[] directions; private ParticleSystem particles; void Start()
2021-10-07 10:37:32
3580
1
原创 unity场景中寻找挂的脚本
在开发中往往会遇到一个问题:不知道整个场景中究竟有哪些物体挂载了某一个脚本。如果挨个查找太麻烦了,下面有一种方法可以快速找到解决这个问题。在windows找到using UnityEngine;using UnityEditor;public class FindMissingScriptsRecursively : EditorWindow{ static int go_count = 0, components_count = 0, missing_count = 0;
2021-09-23 17:50:40
1827
原创 unity摄像机视角跟随物体旋转改变
var rotation = Quaternion.LookRotation(objname.transform.TransformVector(Vector3.forward), objname.transform.TransformVector(Vector3.up)); rotation = new Quaternion(0, rotation.y, 0, rotation.w); ...
2021-09-17 16:11:35
832
原创 unity动态加载UGUI图片
工作中用到点击UI图片切换成另外一个图片,不说废话直接上代码using UnityEngine.UI;//UI引用 Texture2D t; public Image Mute; public void Mute_() { t = (Texture2D)Resources.Load("picture/静音"); Sprite temp = Sprite.Create(t, new Rect(0, 0, t.width, t.
2021-09-03 15:45:17
539
原创 unity制作自行排序
创建UI在Canvas下添加Scroll View 如图并且在content下添加组件然后在把需要自动排序的组件添加到content下可自行排序
2021-06-16 14:54:02
664
原创 unity点击UI防止触碰UI后面物体
if (Input.GetMouseButton(0) & !EventSystem.current.IsPointerOverGameObject()) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) {
2021-06-04 16:11:26
1343
原创 unity InputField限制输入指定数字或字母
public InputField QJ_Input int value; Regex reg = new Regex("^[f0-1]+$"); if (reg.IsMatch(QJ_Input.text)) { value = Convert.ToSingle(QJ_Input.text); } ...
2021-05-28 16:33:32
3227
原创 unity InputField按下tab自动切换
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using UnityEngine.EventSystems;namespace Test{ public class ChangeCursorTest : MonoBehaviour, ISelectHandler, IDeselectHandler { private
2021-05-28 09:47:22
504
原创 unity点击button获取指定符号前字符
public void BtClick() { var button = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject; Debug.Log(button.name); string str = button.name; str = str.Substring(0, str.LastIndexOf("_")); ...
2021-04-28 16:23:27
322
原创 unity点击UI自动生成物体和销毁
点击button生成预制物体,用字典保证不重复生成,并且销毁 public GameObject objname;//需要寻找物体的名称 public Transform parent;//ui父物体 public Dictionary<string, int> predic; int dicindex = 0; public GameObject[] WaterRoomCount ; private void Start() {
2021-04-28 15:04:58
1960
1
原创 unity打印输出自动生成文本
在一次项目中需要打印出场景内物体相同的名字,并且生成txt也是从别人处学习,同样勿怪代码复制放在物体上直接使用 可生成 ,可以自定义生成位置,注意要在path前加上@注:以下代码是遍历场景内所有名称相同的物体using System;using System.Collections;using System.Collections.Generic;using System.IO;using UnityEngine;public abstract class MonoSingletonMan
2021-04-26 14:44:45
1656
原创 unity 报错FormatException: Input string was not in the correct format System.Int32.Parse
写代码时需要string转int 因此使用 int.Parse(content); 但发现报错FormatException: Input string was not in the correct format System.Int32.Parse。。。。。。后来在网上寻找到答案 string zhi = content; if (int.TryParse(content,
2020-10-29 10:50:27
4993
原创 unity动态加载预制物体
//加载Resoureces文件夹下名字叫做display的预制物体 GameObject pre = (GameObject)Resources.Load("display"); //实例化到场景中 GameObject instancess = Instantiate(pre) as GameObject; //将物体绑定到父物体下面 instancess.parent = btn.transform; //给物体赋值坐标 instancess. localPosition= new Ve
2020-10-10 17:00:20
2960
原创 unity 物体旋转两种方式
两种旋转第一种给物体一个指定角度进行旋转Quaternion q = Quaternion.Euler(0, 0, euler);Rotate.transform.rotation = Quaternion.RotateTowards(Rotate.transform.rotation, q, Time.deltaTime * 20);第二种让物体一直朝着固定方向旋转this.transform.Rotate(Vector3.forward * 10);...
2020-09-25 15:19:02
1383
原创 unity动态加载Resources并且实例化
直接附上代码,在resources文件家中存在预制物体就可以GameObject Prefab = (GameObject)Resources.Load("Prefabs/task1"); Prefab = Instantiate(Prefab); Prefab.transform.parent = parent; Prefab.transform.position = Vector3.zero; Prefab.transform.localScale = Vector3.one;将预制物体放在需要位置,
2020-09-24 16:49:47
1237
原创 unity 鼠标悬浮在物体上显示名称(读取xml文件)
实现鼠标放在某一个物体上显示物体的名称或者其他信息,用xml储存名称等信息,鼠标触碰时触发条件附上代码比较垃圾,但是可以使用using System.Collections;using System.Collections.Generic;using UnityEngine;using System.Xml;using System.IO;using UnityEngine.UI;using System;public class xmltest : MonoBehaviour {
2020-08-25 16:39:04
1633
原创 unity3d ColorHex转换成color颜色
ColorUtility.TryParseHtmlString(sting Hex, out Color);
2020-08-12 16:51:40
621
原创 unity 摄像机围绕某个物体进行旋转放大缩小
脚本通过以一个物体为中心点,来控制摄像机围绕物体旋转缩放 ,脚本挂在摄像机上即可,target是需要观看的物体public GameObject target;private float dis;public float xSpeed = 200, ySpeed = 200, mSpeed = 10; //移动速度public float yMinLimit = -50, yMaxLimit = 50; //摄像
2020-08-06 10:49:31
1642
2
原创 unity获取HTC手柄的每个按键
在使用htc中会用到的一些手柄按键SteamVR_TrackedObject trackdeObjec;void Awake() //获取手柄上的这个组件{trackdeObjec = GetComponent<SteamVR_TrackedObject>();}void trackdeObjec_(){ var device = SteamVR_Controller.Input((int)trackdeObjec.index); if (device.GetPre
2020-07-17 09:56:29
1307
原创 unity动态修改物体颜色(改变材质球Shader)
有时候我们可能会动态创建、或者加载一些物体需要改变一下物体的基本颜色,但是一个材质球我们可能用在很多物体上,所以就需要用到下边的这个方法;private Material cubeMat;//使用代码动态创建void Update(){if (Input.GetMouseButtonDown(0))cubeMat= new Material(Shader.Find(“Custom/NewSurfaceShader”));//在project窗口中找到这个shader脚本float r= 100/
2020-07-15 16:54:00
8238
1
unity 可视化UI导入XCharts并编译通过后,Unity编辑器的菜单栏会显示XCharts,这时可以开始使用XCharts了
2025-03-27
切割模型脚本,可用于切水果之类的切割游戏
2023-11-22
unityEZReplayManager1.53.unitypackage
2020-07-15
See-Through System1.6b.rar
2020-02-29
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人