- 博客(41)
- 收藏
- 关注
原创 unity摄像机定位物体功能
using System.Collections;using System.Collections.Generic;using UnityEngine;public class BaseCameraLookAtTarget : MonoBehaviour{ public Transform mainCameraTr; //主摄像机 public Transform lookAtTarge.
2022-05-26 16:40:38
1624
原创 unity摄像机旋转缩放功能
using UnityEngine;public class CameraController : MonoBehaviour{ public float maxScroll = 2; public float minScroll = 10; public float maxYRotateAngles = 80; public float minYRotateAngles = 10; public float rotateSpeed = 5; pub.
2022-05-26 16:38:28
528
原创 unity 百度语音识别
地址:Unity中使用百度语音识别及语音合成【含源码】github:GitHub - zhenghongzhi/WitBaiduAip: Unity3d中的百度语音识别和语音合成Restful接口的封装,适用于全平台
2021-09-18 15:48:55
262
转载 unity 线框效果
// modified version of "VR/SpatialMapping/Wireframe.shader" from Unity 5.5f2// added colors, discard option, removed stereo support and color by distanceShader "UnityLibrary/Effects/Wireframe"{ Properties { _LineColor ("LineColor", Color) = (1,1,1.
2021-05-11 16:40:03
670
原创 unity 设置软件运行分辨率
打包pc后,在exe的同级目录创建一个名为分辨率的txt ,格式类似为1920=1080将下面脚本放到第一个场景即可using System;using System.Collections;using System.Collections.Generic;using System.IO;using System.Runtime.InteropServices;using UnityEngine;public class WindowsMode : MonoBehaviour{
2021-04-20 15:10:06
1746
转载 Unity 获取鼠标点击转换世界坐标
/// <summary>/// 获取鼠标点击坐标/// </summary>Vector3 screenPosition;//将物体从世界坐标转换为屏幕坐标Vector3 mousePositionOnScreen;//获取到点击屏幕的屏幕坐标Vector3 mousePositionInWorld;//将点击屏幕的屏幕坐标转换为世界坐标public Vector3 MouseFollow(){//获取鼠标在相机中(世界中)的位置,转换为屏幕坐标;screenP.
2021-04-19 14:14:09
5386
原创 unity 拖拽ui 到场景生成对应模型
using System.Collections;using System.Collections.Generic;using UnityEngine;public class SelectObjManager : MonoBehaviour{ private static SelectObjManager _instance; public static SelectObjManager Instance { get { return _instanc.
2021-04-07 15:25:23
1138
6
转载 unity 线框效果
https://blog.youkuaiyun.com/u014361280/article/details/106533954/
2021-03-31 14:13:10
399
原创 unity打开ppt 打包后也可以运行
代码如下using Aspose.Slides;using System;using System.Drawing.Imaging;using System.IO;using UnityEngine;using UnityEngine.UI;public class LoadPPT : MonoBehaviour{ public Image pptImage; private Presentation presentation; private int inde
2021-03-30 12:35:01
1705
11
原创 Unity 检测程序长时间无操作
using System.Collections;using System.Collections.Generic;using UnityEngine;public class LongTimeNoInput : MonoBehaviour { public float maxTimeOffset = 10;//检测时间间隔 private float lasterTime; private float nowTime; private float offsetTime; .
2021-03-19 14:06:39
926
转载 unity UniversalMediaPlayer pc平台下插件打包后无法播放视频
原创链接:https://blog.youkuaiyun.com/qq_39873732/article/details/108667393解决办法:打开UMPPostBuilds.cs脚本修改publicstaticvoidBuildWindowsPlayer64(stringpath,UMPSettingssettings)这个方法 public static void BuildWindowsPlayer64(string path, UMPSettings settings) {...
2021-03-12 18:45:25
2614
原创 unity 以文件形式 保存场景对象的Transform信息
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;using System.Runtime.Serialization.Formatters.Binary;using System.IO;[Serializable]public class ObjectData{ public float xPos, yPos, z.
2021-01-07 16:37:15
1021
2
原创 unity 使用 VectorLine 画线(包含画线过程)
需要以下两个插件:Vectrosity和DOTween将下面脚本挂在要绘制连线的对象的父物体上,lineMaterial材质球使用Vectrosity插件自带的SolidColor Shaderusing System.Collections;using System.Collections.Generic;using UnityEngine;using Vectrosity;using DG.Tweening;public class DawnLine : MonoBehaviour
2020-12-29 14:19:48
1982
原创 Unity 公告板效果
using System.Collections;using System.Collections.Generic;using UnityEngine;public class LookAtTarget : MonoBehaviour{ public bool mainCameraAsTarget; public Transform target; public bool rever; public bool freezeX; Vector3 dire;.
2020-12-22 09:32:24
362
原创 unity 帮助不继承mono的脚本 开启协程
using UnityEngine;using System.Collections;/// <summary>/// Mono behaviour helper. Starts the coroutine in not MonoBehaviour class./// </summary>/// public static class MonoBehaviourHelper { /// <returns>The coroutine.</r.
2020-12-16 09:42:26
2313
1
原创 unity editor 菜单的选择状态
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;public class MyModeEditor : Editor{ [MenuItem("YY/GameMode/Debug")] public static void DebugMode() { UpdatePLCSignalSyncMode(SignalSyn.
2020-11-10 15:29:35
530
原创 Unity 2018 代码保存预制体
var prefab = UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(gameObject); if (prefab != null) { string path = UnityEditor.PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(prefab); Deb.
2020-11-10 14:50:44
1078
原创 unity post 协议与服务器交互
unity客户端在与服务器进行数据传输的时候,有时候服务器那边会指定post协议,并且指定字段等信息,这时候就需要用以下方式进行通讯using System.Collections;using System.Collections.Generic;using System.Text;using UnityEngine;using UnityEngine.Networking;public class Test : MonoBehaviour{ // Start is called
2020-09-14 09:49:58
378
原创 Unity录音并且保存文件(去掉录音无效片段)
将以下代码复制,挂在场景中(也可以将此脚本写成不继承mono的单例)开始录音方法StartRecord。停止录音方法StopRecord,参数为要保存的文件名,这里将文件保存到Application.persistentDataPath路径下using UnityEngine;using System.Collections;using System.Collections.Generic;using System;using System.IO;/// <summary&g
2020-06-08 23:40:13
754
转载 Unity 制作伪全息
原文链接:https://blog.youkuaiyun.com/weixin_41185053/article/details/85680163?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-15.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-15
2020-05-30 16:54:49
512
原创 Unity ab包 shader丢失
有时候我们会遇到这么一种情况,在pc上开发各种特效表现都是正常的,但是打成ab包放到移动端进行测试就发现有的特效显示并不正常。这个时候点击Edit→Project Setting→Graphics,在这里把你使用的shader加进去,重新生成ab包就可以了...
2020-04-08 10:37:37
1545
原创 Unity Application.OpenURL Unity打开网页链接
一般情况下,在电脑上使用Application.OpenURL可以正常打开网页,但是如果网页以www开头,例如www.baidu.com,在电脑上可以正常打开,但是发布成apk后就没有反应了,此时应将Application.OpenURL("www.baidu.com")改为Application.OpenURL("http://www.baidu.com");参考链接:https://sta...
2020-03-27 21:08:06
6930
转载 flutter 环境配置 Android sdkmanager tool not found(当安卓sdk目录没有tools文件夹用此解决方案)
问题的原因就是,电脑是全新的环境,下载的最新版本的Android Studio 3.6.1。在这个Android Studio版本中,默认情况下是不会安装Android SDK Tools的。居然是Obsolete,废弃的。也没去研究为啥取消了,反正只要安装上应该就可以了。主要默认这个选项也是看不到的。记得将Hide Obsolete Packages这个选项勾选取消掉。默认是勾选...
2020-03-19 10:07:31
4085
原创 Unity 生成 Excel表格
Unity生成Excel需要EPPlus这个库,Editor状态可以使用,打包后需要加入 I18N.CJK 和 I18N 这两个库代码如下: private void SaveExcel() { OpenFileName ofn = new OpenFileName(); ofn.structSize = Marshal.SizeOf(o...
2020-03-01 16:48:13
2326
2
转载 Unity 打包apk最详细教程
https://blog.youkuaiyun.com/peng_1993/article/details/91803721
2020-03-01 15:22:03
1231
原创 Unity 读取Windows 选中的Excel
需要Excel和System.Data两个库using System;using System.Collections;using System.Collections.Generic;using System.IO;using System.Runtime.InteropServices;using UnityEngine;using UnityEngine.UI;using...
2020-02-27 23:11:10
256
原创 Unity 打开Windows 选择文件
实现效果:using UnityEngine;using System.Collections;using System;using System.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]public class OpenFileName{ ...
2020-02-27 21:47:16
662
原创 Unity调用系统对话框
Unity做PC的时候,如果对于一些简单的提示框没有过多要求,可以调用Windows系统对话框效果如下:代码很简单public class DllTest{ [DllImport("User32.dll", SetLastError = true, ThrowOnUnmappableChar = true, CharSet = CharSet.Auto)] pu...
2020-02-27 21:23:22
710
原创 Unity 不规则按钮 点击
当美术给了一张透明的图当作按钮时,又不想透明的部分响应事件,就需要这个功能了using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.EventSystems;public class UnregularButtonWithPixel : MonoBehaviour{ ...
2020-02-27 21:05:45
334
转载 Unity 使用ICSharpCode.SharpZipLib解压zip文件
using System;using System.IO;using UnityEngine;using ICSharpCode.SharpZipLib;using ICSharpCode.SharpZipLib.Zip;using System.Collections;using System.Collections.Generic;using System.Text;p...
2020-02-27 20:23:27
2357
3
原创 Unity3d ,cocos 写lua一款非常好用的ide
https://github.com/jiangzheng1986/LuaPerfect也可以进群下载:QQ群: LuaPerfect官方群(932801740) 群里有使用教学视频
2020-02-27 19:43:29
535
转载 Unity 打包后错误捕捉
Unity在Editor开发时可以在控制台查看错误,然而一旦发布,这些错误就无法被开发人员直接看到,会引起程序不按照预期进行导致表现不正确。好在Unity本身具有非常强大的日志捕获,具体代码如下using UnityEngine;using System;using System.IO;using System.Diagnostics;using System.Collections...
2020-02-27 19:38:31
1091
2
转载 lua invalid pattern capture
lua中string.gsub做替换时当pattern中含有)这个字符时(也不一定是这个字符,只不过我碰到的是)会报错-- 字符串替换【不执行模式匹配】-- s 源字符串-- pattern 匹配字符串-- repl 替换字符串---- 成功返回替换后的字符串,失败返回源字符串string.replace = function(s, pattern, repl)...
2020-02-21 12:32:56
767
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人