
unity3d
思玉
码农
展开
-
unity 圆形障碍,避障算法,动态避障,静态避障,屎壳郎推屎回娘家
1:根据,屎和娘家的位置做计算,不管屎在哪里,获取朝向娘家,屎后面一定距离的位置。3:在推屎过程中出现不可抗拒因素,即时使用Update计算获取新的推屎路线,2:屎壳郎需要跑到屎后面,推屎回娘家,需要进行避障算法。Unity3d圆形障碍避障算法,动态避障,静态避障。原创 2023-10-25 17:25:54 · 801 阅读 · 0 评论 -
unity shader 幽灵材质
【代码】unity shader 幽灵材质。原创 2022-08-29 17:44:53 · 1218 阅读 · 1 评论 -
unity shader 从RGB到HSV的互转(HSVToRGB)(RGBToHSV)
1.RGB RGB是从颜色发光的原理来设计定的,通俗点说它的颜色混合方式就好像有红、绿、蓝三盏灯,当它们的光相互叠合的时候,色彩相混,而亮度却等于两者亮度之总和,越混合亮度越高,即加法混合。 红、绿、蓝三个颜色通道每种色各分为256阶亮度,在0时“灯”最弱——是关掉的,而在255时“灯”最亮。当三色灰度数值相同时,产生不同灰度值的灰色调,即三色灰度都为0时,是最暗的黑色调;三色灰度都为255时,是最亮的白色调。 在电脑中,RGB的所谓“多少”就是指亮度,并使用整数来表示。通常情况下原创 2022-01-14 15:04:48 · 2142 阅读 · 0 评论 -
unity ui 扫光shader
_LightTex 1:扫光贴图_Color 2:扫光颜色_Intensity 3:强度_Speed 4:运动速度_Angle 5:扫光贴图uv中心点旋转Shader "Unlit/UIWalklight"{ Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {} _LightTex ("Light", 2D) = "black" {} _Color ("Color",.原创 2021-07-28 16:20:20 · 2490 阅读 · 0 评论 -
unity 卡通动物 shader 包含边缘光,ramp,描边
unity 卡通动物 shader 包含边缘光,ramp,描边上shaderShader "Unlit/TestShader"{ Properties { _Diff ("Diff", 2D) = "white" {} _MainColor ("MainColor", Color) = (0,0,0,1) //模型主颜色 _RAMP ("RAMP", 2D) = "white" {} _Light ("Light", Vector) =原创 2021-06-25 15:40:47 · 890 阅读 · 2 评论 -
unity 水晶 石头 shader
unity 水晶 石头 shader上shaderShader "Unlit/CrystalTest"{ Properties { _LayerTex ("Layer Texture", 2D) = "white" {} _LayerTint("Layer Tint", COLOR) = (1,1,1,1) _LayerHeightBias("Layer Height Start Bias", Range(0.0, 0.2)) = 0.1 _HeightTex ("Height原创 2021-06-25 15:35:59 · 2024 阅读 · 0 评论 -
unity 眼球效果 eyes shader
上图注意:为了避免虹膜在莫个光照角度产生平板光,需要把模型虹膜部分微微往下凹上shader 眼睛部分和眼睛前面晶体部分是分开2个shader眼睛部分Shader "Hero/Eye" { Properties{ //cornea角膜 //Iris虹膜 黑眼球 //sclera巩膜 眼白 _Lum("Luminance", Range(0, 10)) = 4 _MainTex("Base (RGB)", 2D) = "white" {} _IrisColor("cornea原创 2021-05-19 17:06:31 · 2734 阅读 · 7 评论 -
unity 为自己脚本增加材质编辑面板 MaterialEditor
unity 为自己脚本增加材质编辑面板 MaterialEditor如图上代码using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;[CustomEditor(typeof(AraTrail))]public class TrailInspector : Editor{ AraTrail araTrail; void OnEnab原创 2021-05-18 20:00:56 · 2003 阅读 · 7 评论 -
unity 特效制作快捷辅助工具
unity 特效制作快捷辅助工具通过选中节点,鼠标中间点击,弹出配置好的快捷粒子,快速创建模块化粒子上码(注意effectFastList 集合里面的数据需要自己填充)using System.Collections;using System.Collections.Generic;using System.IO;using System.Xml;using UnityEditor;using UnityEngine;public class EffectHelpQuick{ [原创 2021-03-24 15:13:56 · 542 阅读 · 3 评论 -
unity Animation Legacy快捷设置工具
unity Animation Legacy快捷设置工具上码(注意:上面有2张资源图片,需要放在Editor Default Resources文件夹下)using System.Collections;using System.Collections.Generic;using UnityEditor;using UnityEngine;public class AnimationLegacy{ static Texture2D AnimationLegacy_A;//按钮图片1原创 2021-03-24 15:06:26 · 510 阅读 · 0 评论 -
unity 摄像机导入 3dmax 带fov
unity 摄像机导入 3dmax 带fov先看效果图编写unity 工具1,先把导出的模型拉到摄像机节点下,需要在hierarchy选中摄像机为根节点,然后导出 ,2,导出文件路径在工程Assets同目录下的ExportedObj文件夹里面,这里使用的导出obj插件工具代码主要用要保存摄像机位置,旋转,fov ,等一系列参数, 用与在3dmax 进行还原 Transform[] selection = Selection.GetTransforms(SelectionMod原创 2021-01-12 15:21:54 · 2939 阅读 · 1 评论 -
unity shader 阴影强度颜色和自定义画阴影
有图有真相:上图的操作需求1: 头发部分不受阴影影响2:面部阴影强度调节3:面部阴影强度渐变调节4:面部阴影颜色调节5:其他地方阴影效果不变(衣领部分)上码:Shader "Unlit/阴影强度"{ Properties { _MainTex ("_MainTex", 2D) = "white" {} _Shadows_mask ("Shadows_mask", 2D) = "white" {} _Shadows_mask_pw ("Shadows_mask_pw", 2原创 2020-12-04 19:21:09 · 2025 阅读 · 0 评论 -
unity shader 溶解,上下左右,cutoff
unity shader 溶解,上下左右,cutoffShader "cutoff" { Properties { _Cutoff ("Cutoff", Float ) = 0 _Mask ("Mask", 2D) = "white" {} _Diffues ("Diffues", 2D) = "white" {} } SubShader { Tags { "Queue"="Al原创 2020-11-18 19:40:21 · 1172 阅读 · 0 评论 -
unity shader 阴影强度控制 增加mask通道图
阴影强度控制可以修改灯光参数 strength 来进行控制同样也可以来shader 上进行控制下面还增加了mask通道图 用来控制模型不同部位的阴影强度不一样上图 上码Shader "Unlit/阴影强度"{ Properties { _MainTex ("_MainTex", 2D) = "white" {} _Shadows_mask ("Shadows_mask", 2D) = "white" {} //阴影mask _Shadows_R_PW ("Shadows_R_原创 2020-11-18 17:18:38 · 1080 阅读 · 0 评论 -
unity 陀螺仪 物体旋转和移动效果
unity 陀螺仪 物体旋转和移动效果直接上码 带注释public class SDKGyroController : MonoBehaviour {//陀螺仪是否存在 class GyroGameObject { public GameObject go = null; public bool m_IsRotate = false; public bool m_IsBack = false; public Vector3 m_原创 2020-11-04 16:56:53 · 2507 阅读 · 0 评论 -
unity shader 闪烁+流光
unity shader 闪烁+流光 上图上码Shader "Unlit/流光闪烁"{ Properties { _MainTex ("_MainTex", 2D) = "white" {} _TwinkleSpeed ("TwinkleSpeed", Float ) = 1 //闪烁速度 _TwinkleColor ("TwinkleColor", Color) = (0.5,0.5,0.5,1) //闪烁颜色 _TimeTex("TimeTexture",2D)="whi原创 2020-11-04 16:22:51 · 3744 阅读 · 0 评论 -
unity shader 华为畅玩7,联发科CPU兼容记录
先来看下 问题的表现shader 里面用到了lightDirectionnormalDirection 但是因为没用规范化,在华为畅玩7,机器上出现表现不一**所以紧记 时刻做规范化,这里修改成saturate(lightDirectionnormalDirection) 即可**...原创 2020-10-28 15:12:46 · 387 阅读 · 0 评论 -
通过bytes文件头判断图片格式
图片文件可以完全根据前面的两个字节的二进制数字进行判断。比如说bmp类型的,相对应的就是0x42 0x4d,0x42=416+2=66, 0x4d=416+13=77我们就可以在代码中这样写: if (www.bytes[0] == 66 && www.bytes[1] == 77) { BitMap g =newBitMap(); var tex = g.ParseBmp(www.bytes); }几种常见图原创 2020-10-14 20:44:46 · 2064 阅读 · 0 评论 -
开源解决方案,随笔记录
Unity + Winform 实现窗口置顶、全屏和边框设置、任务栏操作:https://github.com/U3DC/Unity-Winform-Solution支持运行时导入、导出OBJ文件https://github.com/U3DC/Unity_OBJ-file_Import_And_Export文件浏览,类似windows的文件选择窗口https://github.com/U3DC/UnitySimpleFileBrowser(Unity热门插件UnWebView作者)的自动打包方案原创 2020-10-13 17:48:13 · 513 阅读 · 1 评论 -
unity shader 优化变体以及使用IPreprocessShaders剥离
当 shader 使用:#pragma multi_compile _ A1 A2 A3#pragma multi_compile _ B1 B2 B34个multi_compile,2组,一共16个情况3档,2个平台,6个情况,总计16*6=96个变体添加处理:using System.Collections.Generic;using UnityEditor.Build;using UnityEditor.Rendering;using UnityEngine;public cl转载 2020-09-22 15:27:33 · 2700 阅读 · 0 评论 -
unity shader 边缘光,内发光,外发光,轮廓边缘光,轮廓内边缘光,轮廓外边缘光
先上一张图片,看下实际效果1:黑色为模型主color2:白色为内发光,轮廓内边缘光3:红色为外发光,轮廓外边缘光Shader "Unlit/边缘光"{ Properties { _MainColor ("MainColor", Color) = (0,0,0,1) //模型主颜色 _InSideRimColor ("InSideRimColor", Color) = (1,1,1,1)//内边缘光颜色 _InSideRimPower("InSideRimPower", R原创 2020-09-10 23:07:06 · 8914 阅读 · 2 评论 -
unity google admob ios 接入 聚合激励广告适配器
下面说下躺坑主要是接入google admob 聚合激励广告适配器 ,开启facebook ,unity,admob 广告使用sdk框架接入sdk下载地址:https://developers.google.com/admob/ios/download1:导入主要的库GoogleMobileAds.frameworkGoogleAppMeasurement.frameworkGoogleUtilities.frameworknanopb.framework对应聚合各个平台sdk 地址:h原创 2020-09-09 21:20:10 · 1397 阅读 · 0 评论 -
unity android ping代码 随笔
这里是使用的android 自己的Exec 执行ping 并且获取到最终结果废话不多,先上java 代码 public static void RuntimeExecAsync(Context context, final String command) { Thread thread = new Thread() { public void run() { StringBuffer stringBuffer = new StringBuffer(); Process p =原创 2020-08-19 20:02:01 · 621 阅读 · 0 评论 -
GfxDeviceMetal::GetPipeline(GfxDeviceMetal::PipeKey const&) + 8207248 (GfxDeviceMetal.mm:432)
unity ios 加载资源 CrashedHardware Model: iPhone9,2Process: legends [1828]Path: /private/var/containers/Bundle/Application/F18FEE9D-E1BE-4908-B1D7-677DCE781FC9/legends.app/legendsVersion: 1.4.94.5371 (1.4.94)Cod原创 2020-08-19 19:20:11 · 1060 阅读 · 0 评论 -
unity3d moba游戏,英雄展示优化浅谈
如图英雄展示模块,性能浅谈1:fps处理这里主要是通过对线上大数据分析和资源制作的实际情况来找到平衡点,我们的数据都是东南亚市场,实际硬件水平比较低,下图,是我们对应的英雄在玩家性能市场的实际表现情况1:包体大小控制2:当前show hero 过程中的平均fps (要求在26以上)3:当前英雄资源加载的耗时 (要求在900ms以下)对应上面2点数据对实际的资源情况进行分析,下图包体大小占比:particle(10-25%) texture(40-70%) mesh(7-20%)原创 2020-07-23 14:20:48 · 548 阅读 · 0 评论 -
unity3d android 图片插入相册显示 Insert Image To MediaStore
unity3d android 图片插入相册显示废话不多直接上代码 public static void InsertImageToMediaStore(string filePath, string fileName) { if (string.IsNullOrEmpty(filePath) || string.IsNullOrEmpty(fileName)) { return; }#if (UNITY_ANDRO原创 2020-05-09 18:52:19 · 335 阅读 · 0 评论 -
unity3d android获取app 包名
unity3d android获取app 包名废话不多直接上代码 public static string GetPackageName() { string _strPackageName = "null"; if (string.IsNullOrEmpty(_strPackageName)) { _strPackageName = "null";#if (UNITY_ANDROID && !UN原创 2020-05-09 18:44:31 · 1487 阅读 · 0 评论 -
unity3d android 获取是否安装app
unity3d android 获取是否安装app废话不多直接上代码 public static bool IsInstallApp(string packageAndroidName) {#if (UNITY_ANDROID && !UNITY_EDITOR) || ANDROID_CODE_VIEW try { using (AndroidJavaClass unityPlayer = n原创 2020-05-09 18:41:03 · 435 阅读 · 0 评论 -
unity3d 获取内存 android Used PssMemory
unity3d 获取内存 android Used PssMemory废话不多直接上代码 public static int GetUsedPssMemory() { int memory = -1;#if (UNITY_ANDROID && !UNITY_EDITOR) || ANDROID_CODE_VIEW try { using (AndroidJavaClass unityPlayer = ne原创 2020-05-09 18:32:36 · 1293 阅读 · 0 评论 -
unity3d 获取android 手机所有安装的apk 和包名
unity3d 获取android 手机所有安装的apk 和包名废话不多直接上代码 public static List<string> GetAllApk() { List<string> apks = new List<string>(); #if (UNITY_ANDROID && !UNITY_EDITOR) || ANDROID_CODE_VIEW try原创 2020-05-09 18:30:23 · 572 阅读 · 0 评论 -
unity3d 获取 Advertising ID
unity3d 获取Advertising ID废话不多直接上代码 public static string GetAdvertisingID() { string _strAdvertisingID = "none"; if (string.IsNullOrEmpty(_strAdvertisingID)) { _strAdvertisingID = "none";#if (UNITY_ANDROID &&原创 2020-05-09 18:27:36 · 1826 阅读 · 1 评论 -
unity3d 获取android id
unity3d 获取android id废话不多直接上代码 public static string GetAndroidID() { string _strAndroidID = "none"; if (string.IsNullOrEmpty(_strAndroidID)) { _strAndroidID = "none";#if (UNITY_ANDROID && !UNITY_EDITOR)原创 2020-05-09 18:25:17 · 1976 阅读 · 0 评论 -
Sub-emitters must be children of the system that spawns them
关于unity引擎相关错误:Sub-emitters must be children of the system that spawns them解答:在编辑器重现方式Particle System 的Sub Emitters 属性里面,绑定的节点,只能是自己的子节点对象如图:Particle System1 的Sub Emitters 属性绑定children节点,同时Particle System2 也绑定了children节点,就会出现这样错误,特效在制作的时候为了方便, 往往去co原创 2020-05-09 17:42:15 · 5567 阅读 · 1 评论 -
unity3d 加载卡顿,File.Exists 罪魁祸首之天坑
File.Exist 是用来判定文件是否存在,然后进行加载的常用逻辑,但也是造成加载卡顿的 罪魁祸首,这里测试,在华为v10 ,1加手机,会特别明显, 我用moto手机测试感觉没什么问题,也许跟手机装的app数量也有关系,总之对于这方法尽量避免使用,下面说明一下这个方法的测试情况:测试机器:华为v10目录下文件数量:13749判定不存在的文件:消耗30ms-45ms不等判定存在的文件...原创 2020-01-14 20:05:10 · 5341 阅读 · 0 评论 -
The AssetBundle 'Memory' could not be loaded because it .. Rebuild the AssetBundle to fix this error
关于unity引擎相关错误:a_1)The AssetBundle ‘Memory’ can’t be loaded because it was not built with the right version or build target.a_2)The AssetBundle ‘hero_fanny_skin.unity3d’ can’t be loaded because it wa...原创 2020-01-14 19:36:17 · 1553 阅读 · 1 评论 -
The AssetBundle 'Memory' can't be loaded because it was not built with the right version or build ta
关于unity引擎相关错误:a_1)The AssetBundle ‘Memory’ can’t be loaded because it was not built with the right version or build target.a_2)The AssetBundle ‘hero_fanny_skin.unity3d’ can’t be loaded because it wa...原创 2020-01-14 19:35:10 · 3328 阅读 · 7 评论 -
unity3d The file none is corrupted!Remove it and launch unity again! Position out of bounds!
关于unity引擎错误:The file none is corrupted!Remove it and launch unity again! Position out of bounds!解答:这个错误是unity 一个cache 的bug1,unity引擎 读取缓冲的时候 cachedreader 条件是用缓冲地址加长度判断,如果没这个错误就从缓冲内存返回数据2,unity的Cach...原创 2020-01-14 19:27:26 · 4903 阅读 · 0 评论 -
unity3d [EGL] Unable to acquire context: EGL_BAD_NATIVE_WINDOW: A NativeWindowType argument does not
对于unity 引擎错误:[EGL] Unable to acquire context: EGL_BAD_NATIVE_WINDOW: A NativeWindowType argument does not refer to a valid native window解答:这个错误的最终抛出,来源不是unity引擎,而是一个OpenGL ES EGL的错误,android和ios都会发生,...原创 2020-01-14 19:20:30 · 5846 阅读 · 0 评论 -
unity3d 加载卡loading 分析, android 之外置sd卡 问题
现在手机很多都可以用插拔式sd卡用来扩充存储大小,但这些外接设备也会引发一些未知的app运行问题,先看一下sd类型可见不同sd卡对io速度也不同,所以对app的影响也又所有不同,在此送上一份可信的数据来看下影响层面上图可以看出资源下载在不同的存储位置,反应的加载资源卡住的比例在外置sd比内置存储要高出1倍。对此我们做了玩家友情提示和资源搬家功能,主要是让玩家知道资源放在内置存储更好,...原创 2020-01-14 18:00:51 · 544 阅读 · 0 评论 -
unity3d 修改高棉字体对unity支持
概述目前unity最新版本也没有对高棉文字进行支持,所以只能通过修改ttf字体文件进行处理在修改过程中发现多数文本阅读软件对高棉字体显示都是有问题的(如wps,notepad++),最后选择了window自己的txt记事本为显示标准,果然全球化最牛b的还是window系统高棉在unity显示问题如图,原始高棉ttf字体在unity显示错误,经过处理字体文件后的显示结果,最后加上逻辑处理就...原创 2019-11-26 21:12:54 · 1550 阅读 · 4 评论