随笔分类 -  unity

摘要:建议改为用InstanceID来判断即Object. GetInstanceID,运行期间保证唯一。 因为Object的判等还有额外的耗时操作,而Int类型的判等就非常快速了。同理,使用Object作为key的数据结构也建议改用InstanceID做key。 阅读全文
posted @ 2018-07-30 15:57 露夕逝 阅读(402) 评论(0) 推荐(0) 编辑
摘要:主要参考了这篇文章: Unity与Android交互方案优化版 链接:https://www.jianshu.com/p/86b275da600e 自己的实现(unity获取内存和温度): android端: unity端: 值得注意的一点,导出的arr包得改一下sdk的 min version和t 阅读全文
posted @ 2018-06-27 17:25 露夕逝 阅读(584) 评论(0) 推荐(0) 编辑
摘要:首先是自定义 然后是脚本 阅读全文
posted @ 2018-05-07 20:19 露夕逝 阅读(3567) 评论(0) 推荐(0) 编辑
摘要:可以在同一Text中插入不同颜色的文字 1 // 将十进制数转换为十六进制数 2 private static string decimalToHex(int value) { 3 string hex = ""; 4 while (value != 0) { 5 int hexValue = va 阅读全文
posted @ 2018-04-26 14:50 露夕逝 阅读(123) 评论(0) 推荐(0) 编辑
摘要:在gramma空间下,勾选与否无关。 在liner空间下,勾选shader会自动将读到的像素作gramma矫正,即x的0.45次方 不勾选,shader读到的就是原始的颜色值 然后unity如果选了gramma空间,会自动将输出颜色做一个伽马矫正,偏暗,相当于拍照对图片的自动处理。 透明通道的值不会 阅读全文
posted @ 2018-03-20 15:33 露夕逝 阅读(7535) 评论(1) 推荐(1) 编辑
摘要:1.二维数组定义 int[,] arr = new int[len0, len1]; 定义一个len0行,len1列的二维数组,这里的len0,len1指的是GetLength(index) 2.遍历方式 int[,] arr = new int[len0, len1]; for (int i = 阅读全文
posted @ 2018-01-26 11:39 露夕逝 阅读(1104) 评论(0) 推荐(0) 编辑
摘要:旋转向量:(将向量(0,0,1)绕y轴旋转90度,变成了(1,0,0)) float angle = Mathf.Deg2Rad*90; Matrix4x4 matrix = new Matrix4x4(new Vector4(Mathf.Cos(angle), 0, -Mathf.Sin(angl 阅读全文
posted @ 2017-10-25 17:04 露夕逝 阅读(309) 评论(0) 推荐(0) 编辑
摘要:官方的api可以直接获取预览图像,如下所示: Tex=AssetPreview.GetAssetPreview(Object m)as Texture; 但是如果prefab是组合体的话(即一个prefab下包含2个或多个子物体),便只返回null。可以算是unity的一个bug吧。 所以需要自己写 阅读全文
posted @ 2017-10-09 16:46 露夕逝 阅读(6361) 评论(0) 推荐(0) 编辑
摘要:当我们在EditMode下需要用脚本批量添加prefab时,可以用 PrefabUtility.InstantiatePrefab(prefab) as GameObject; 注意:如果用GameObject.Instantiate来创建,创建的不是prefab。也就是说当我们在Assets中修改 阅读全文
posted @ 2017-09-22 11:08 露夕逝 阅读(837) 评论(0) 推荐(0) 编辑
摘要:绝对路径->相对路径 string mp =“H:\unity(project)\New Unity Project\Assets\111.mat”; mp = mp.Substring(mp.IndexOf("Assets")); mp = mp.Replace('\\', '/'); 变成Ass 阅读全文
posted @ 2017-09-21 00:23 露夕逝 编辑
摘要:EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); 阅读全文
posted @ 2017-09-11 11:04 露夕逝 阅读(204) 评论(0) 推荐(0) 编辑
摘要:GUILayout.Label ("Shading", EditorStyles.boldLabel); EditorGUILayout.Space (); InspectorSupport.Explanation ("Cloud", "Set the high level properties f 阅读全文
posted @ 2017-08-31 14:36 露夕逝 阅读(290) 评论(0) 推荐(0) 编辑
摘要:string path = EditorUtility.SaveFilePanelInProject("选择要创建云Prefab的路径", "cloud.prefab","prefab","请输入prefab名","Assets/Prefab/"); 阅读全文
posted @ 2017-08-22 16:33 露夕逝 阅读(310) 评论(0) 推荐(0) 编辑
摘要:做mesh导出的时候遇到了这个问题。 最后解决: 存储mesh数据:AssetDatabase.CreateAsset(meshfilter.mesh, "Assets/" + "Obj/" + go.gameObject.name + ".asset"); 导入Mesh数据:Mesh m_mesh 阅读全文
posted @ 2017-08-21 11:49 露夕逝 阅读(682) 评论(0) 推荐(0) 编辑
摘要:1 // 2 // Author: 3 // Andreas Suter (andy@edelweissinteractive.com) 4 // 5 // Copyright (C) 2011-2012 Edelweiss Interactive (http://www.edelweissinteractive.com) 6 // 7 8 using UnityEngin... 阅读全文
posted @ 2017-08-01 11:43 露夕逝 阅读(289) 评论(0) 推荐(0) 编辑
摘要:原链接:http://www.cnblogs.com/oilcode/p/6927951.html 阅读全文
posted @ 2017-07-24 16:25 露夕逝 阅读(376) 评论(0) 推荐(0) 编辑
摘要:using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; public class CombineMesh : EditorWindow { [MenuItem("地图/合并Mesh")] static void AddWindow() ... 阅读全文
posted @ 2017-07-21 11:17 露夕逝 阅读(3072) 评论(0) 推荐(0) 编辑
摘要:1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 5 public class test : MonoBehaviour 6 { 7 public Transform parent; //这个parent下面挂着四个物体 8 publ... 阅读全文
posted @ 2017-07-15 12:50 露夕逝 阅读(747) 评论(0) 推荐(0) 编辑
摘要:效果图: 阅读全文
posted @ 2017-07-11 15:45 露夕逝 阅读(2494) 评论(0) 推荐(0) 编辑
摘要:新的方法的原理。每次对象坐标改变时,先记录下改变前其n圈内的格子坐标,然后算出改变后n圈内的格子坐标,后者全部setActive(true).后者减去前者作为显示对象。前者减去后者作为隐藏对象 1 using System.Collections; 2 using System.Collection 阅读全文
posted @ 2017-04-10 10:40 露夕逝 阅读(418) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示