unity3d editor log输出log为什么要想换入一个对象

unity3d(95)
我觉得Unity里面的Transform 和 GameObject就像两个双胞胎兄弟一样,这俩哥们很要好,我能直接找到你,你也能直接找到我。我看很多人喜欢在类里面去保存GameObject对象。解决GameObject.Find()无法获取天生activie = false的问题。
& & &private&GameObject&root&;
我觉得你最好不要保存GameObject ,而是去保存Transform ,因为Transform下的方法要比GameObject多,使用频率也要高很多。
& &&private&Transform&root&;
其实我心里一直有个疑问,为什么unity不把GameObject和Transform合并成一个对象。
1.GameObject.Find()
通过场景里面的名子或者一个路径直接获取游戏对象。
& &&GameObject&root&=&GameObject.Find(“GameObject”);
我觉得如果游戏对象没再最上层,那么最好使用路径的方法,因为有可能你的游戏对象会有重名的情况,路径用“/”符号隔开即可。
& &&GameObject&root&=&GameObject.Find(“GameObject/Cube”);
GameObject.Find()使用起来很方便,但是它有个缺陷如下图所示,就是如果你的这个GameObject天生acive = false的话。那么你用GameObject.Find()是永远也无法获取它的对象的。如果对象都获取不到,那么对象身上脚本啊 组件啊啥的都是获取不到的,变成了没有意义的对象。
就这个问题我查过很多资料,最终也无果。。但是我用另外一个巧妙的办法可以解决它。(后面详解)或者你也可以提前把所有的游戏对象保存在内存中。
GameObject.Find()方法在游戏中的使用频率很高。但是它也很消耗性能,你可以想想它的原理肯定也是用类似递归的形式来做的,那么我们就要尽量更少的调用GameObject.Find()方法,可以把获取的游戏对象,保存在内存里,这是再好不过的选择了。 尤其是在Update方法中不要去 Find()游戏对象!!
2 .Transform.Find()
还记得上面我说过用GameObject无法获取天生acive = false的游戏对象,如果你用Transform.Find()的话就可以很好的获取,另外Unity还提供了一个Transform.FindChind()的方法,这个方法未来会被unity废弃,大家最好就别用了,用Transform.Find()可以取代。
如下代码,我们先获取顶级对象root 。接着用Find()去找它的子节点”xxxx”的对象,无论”xxxx”对象是否active = true 都是可以直接找到对象的。
GameObject
GameObject.Find(&GameObject&);&&&&&&
GameObject
=&&root.transform.Find(&xxxx&).gameObject;
&&&&&&&&&&xxxx.SetActive(true);
Find()方法只能直接去找子节点,如果你想找 孙节点,那么可以用”/“符号把层级关系隔开,找起来很方便。同样无论”xxxx”对象是否active = true 都是可以直接找到对象的。
&&&&GameObject
=&&root.transform.Find(&xxxx/Cube&).gameObject;
值得注意的是,unity规定了比如父节点active = true 并且子节点的 active = true 都满足的情况下 才能全部显示。使用Transform.Find()可以很方便的获取游戏对象,因为有了游戏对象,那么它身上的脚本啊组件啊什么的都可以很方便的获取到。
但是Transform.Find()必须要保证你的顶级父对象的activity = true。举个例子,你做了一个场景有一些地图你在场景里面预先activie = false了, 你希望在游戏中的某个时间点把它们都打开 setActive(true)
你可以把“map”节点放在一个active = true的GameObject上,无论是关闭 或者 显示 代码中写起来都很方便。 假如你的map节点就是顶级节点,那么它一旦天生acive = false ,那么你将无法得到它的对象,更无法设置它的属性了。
&GameObject&root&=&GameObject.Find(“GameObject”);&&&&&&&&
GameObject&map&=&&root.transform.Find(“map”).gameO&&&&&&&
&map.SetActive(true);
3. unity 还提供了几个获取游戏对象的方法,但是我个人觉得使用频率不高,这里也简单说两句。
GameObject.FindGameObjectsWithTag(“tag”)
GameObject.FindWithTag(“tag”)
根据一个标记来获取游戏对象,返回一个 或者 一个数组,我个人觉得这个两个方法没啥用,因为既然需要用到标记那么相比这个游戏对象必然是非常特殊的一个,所以我会把它存在内存中。
Object.FindObjectOfType
Object.FindObjectsOfType
Resources.FindObjectsOfTypeAll&
根据一个类型返回Object,比如 GameObject 、Texture、Animation 、甚至还可以是你自己写的一个脚本 的范型。它找起来很方便,可以返回一个 或者一个数组。 我觉得这几个方法其实游戏中也没啥用,不过在编辑器中使用的确实很频繁,比如你要做批量检查场景的工具,查找场景中有没有使用某个特殊类型的对象。 或者查看内存的占用量,看看当前内存中那些Texture没有被释放掉。 等等。
还有一个方法,如果你知道自对象的索引,还可以用下面的方法来获取,参数是index的索引。
transform.GetChild(0)
找到了一个即使隐藏root节点gameObject也能进行查找的方法。
GameObject[]
pAllObjects
(GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject));
(GameObject
pAllObjects)
(pObject.transform.parent
&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&
(pObject.hideFlags
HideFlags.NotEditable
pObject.hideFlags
HideFlags.HideAndDontSave)
&&&&&&&&&&&&
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&
(Application.isEditor)
&&&&&&&&&&&&
&&&&&&&&&&&&&&&&
sAssetPath
AssetDatabase.GetAssetPath(pObject.transform.root.gameObject);
&&&&&&&&&&&&&&&&
(!string.IsNullOrEmpty(sAssetPath))
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&
Debug.Log(pObject.name);
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:2139256次
积分:18924
积分:18924
排名:第492名
原创:55篇
转载:884篇
评论:99条
(4)(1)(1)(15)(21)(4)(6)(42)(4)(1)(5)(2)(11)(18)(21)(43)(3)(4)(11)(5)(3)(2)(7)(2)(4)(39)(60)(24)(86)(118)(92)(2)(2)(2)(1)(5)(18)(3)(17)(20)(97)(59)(35)(20)(1)
(window.slotbydup = window.slotbydup || []).push({
id: '4740881',
container: s,
size: '200,200',
display: 'inlay-fix'Unity(14)
unity3d& 自定义Log文件
using System.IO;
using System.T
using UnityE
using System.Collections.G
public class DebugKit
//private static bool writeD
private static List&string&
private static object locker = new object();
private static A
private static List&string& contentList = new List&string&();
private static List&string& ContentList
List&string& tempList =
lock(locker)
tempList = new List&string&(tempList);
return tempL
/// &summary&
/// Application.dataPath and Application.persistentDataPath can only be accessed in Unity Thread.
/// Do remember to call DebugKit in Unity thread first, not in the work thread you create.
/// &/summary&
static DebugKit()
#if UNITY_STANDALONE_WIN
path = Application.dataPath + &/Log/&;
path = Application.persistentDataPath + &/Log/&;
Application.logMessageReceived += OnApplicationLogMessageR
Initial(&GameHall&);
/// &summary&
/// 初始化
/// &/summary&
/// &param name=&loger&&eg. HallGame|StudGame &/param&
public static void Initial(string loger = &&, bool write = true)
lock (locker)
//writeDown =
logers = new List&string&() { &Log&, &Error&, &Exception&, &TODO& };
string[] ls = loger.Split('|');
for (int i = 0; i & ls.L i++)
if (ls[i] != &&)
logers.Add(ls[i]);
/// &summary&
/// 添加日志输出
/// &/summary&
public static void AddTagger(string tagger)
lock (locker)
if (!logers.Contains(tagger))
logers.Add(tagger);
/// &summary&
/// 移除日志输出
/// &/summary&
public static void RemoveTagger(string tagger)
lock (locker)
if (logers.Contains(tagger))
logers.Remove(tagger);
public static void RegisterLogEvent(Action callback)
lock(locker)
public static void UnregisterLogEvent(Action callback)
lock (locker)
/// &summary&
/// 移除所有日志输出
/// &/summary&
public static void RemoveAll()
lock (locker)
logers.Clear();
public static List&string& TakeContentList()
List&string& tempList =
lock (locker)
tempList = contentL
contentList = new List&string&();
return tempL
/// &summary&
/// &/summary&
public static void Reset()
Initial();
static public void Log(object message)
Log(&Log&, message.ToString());
Debug.Log(message);
public static void Log(string tag, string message)
lock (locker)
//#if UNITY_EDITOR
if (logers.Contains(tag))
string time = DateTime.Now.ToString(&yyyy-MM-dd-HH:mm:ss&);
string trace = &&;
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(true);
System.Diagnostics.StackFrame[] sfs = st.GetFrames();
for (int u = 2; u & sfs.L ++u)
System.Reflection.MethodBase mb = sfs[u].GetMethod();
trace += &\t& + mb.DeclaringType.FullName + &:& + mb.Name + &() (at & + mb.DeclaringType.FullName.Replace(&.&, &/&) + &.cs: & + sfs[u].GetFileLineNumber() + &)\r\n&;
string logContent = time + &#(& + tag + &) =& & + message + &\r\n& +
Debug.Log(logContent);
contentList.Add(logContent);
if (logged != null) logged();
if (/*writeDown ||*/tag == LogType.Error.ToString() || tag == LogType.Exception.ToString())
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
using (StreamWriter w = new StreamWriter(path + DateTime.Now.ToString(&yyyy-MM-dd HH:mm:ss&) + &.txt&, true, Encoding.UTF8))
w.WriteLine(logContent);
w.Flush();
w.Close();
catch(Exception ex)
Debug.Log(&Write log file exception, message = & + ex.Message);
public static void Log(string tag, string format, params object[] args)
Log(tag, string.Format(format, args));
public static void LogError(string format, params object[] args)
Log(LogType.Error.ToString(), string.Format(format, args));
public static void LogException(string format, params object[] args)
Log(LogType.Exception.ToString(), string.Format(format, args));
public static void LogWarning(string format, params object[] args)
Log(LogType.Warning.ToString(), string.Format(format, args));
public static void Todo(string format, params object[] args)
Log(&TODO&, string.Format(format, args));
private static void OnApplicationLogMessageReceived(string condition, string stackTrace, LogType type)
lock (locker)
if (type == LogType.Exception)
Log(LogType.Exception.ToString(), condition + &\r\n& + stackTrace);
else if (type == LogType.Error)
Log(LogType.Error.ToString(), condition + &\r\n& + stackTrace);
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:38451次
排名:千里之外
原创:29篇
评论:13条
(2)(3)(3)(2)(2)(5)(2)(1)(1)(2)(3)(1)(1)(1)(4)
(window.slotbydup = window.slotbydup || []).push({
id: '4740881',
container: s,
size: '200,200',
display: 'inlay-fix'温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
算了,还是留几个字吧。
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
using UnityEusing System.IO;public class MenuTest : MonoBehaviour {& & // Add a menu item named "Do Something" to MyMenu in the menu bar.& & [MenuItem ("MyMenu/Do Something")]& & static void DoSomething () {& & & & Debug.Log ("Doing Something...");& & }& & // Validated menu item.& & // Add a menu item named "Log Selected Transform Name" to MyMenu in the menu bar.& & // We use a second function to validate the menu item& & // so it will only be enabled if we have a transform selected.& & [MenuItem ("MyMenu/Create Prefabs")]& & static void CreatePrefab ()& & {
bool replayAll =
string [] paths = EditorApplication.currentScene.Split(char.Parse("/"));
string _sceneName = paths[paths.Length-1].Replace(".unity","");
Debug.Log("Application.loadedLevelName="+Application.loadedLevelName);
GameObject [] objs = Selection.gameO
& &foreach ( GameObject go in objs) {
string _path = "Assets/Resource/Map/"+_sceneName+"/";
Directory.CreateDirectory(_path);
& & & &string localPath &= _path + go.name + ".prefab";
& & & &if (!replayAll && AssetDatabase.LoadAssetAtPath(localPath, typeof(GameObject))) {
& & & & & &if (EditorUtility.DisplayDialog("Are you sure?",&
& & & & & & & &"One of this prefab already exists. Do you want to overwrite it?",&
& & & & & & & &"Yes",&
& & & & & & & &"No"))
replayAll =
CreateNew(go, localPath);
& & & & & & & & & &
& & & &else
& & & & & &CreateNew(go, localPath);
& &}& & }& & & [MenuItem("MyMenu/Create Prefabs", true)] static bool ValidateCreatePrefab() {
& &return Selection.activeGameObject != }
static void CreateNew( &GameObject obj, & string localPath) { &&
Object prefab &= PrefabUtility.CreateEmptyPrefab(localPath);
Debug.Log("create prefab :"+localPath);
PrefabUtility.ReplacePrefab(obj, prefab, ReplacePrefabOptions.ConnectToPrefab);
PrefabUtility.DisconnectPrefabInstance(obj);
阅读(830)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'Unity3d编辑器开发之所有选中对象保存为预设',
blogAbstract:'
&using UnityEusing UnityEusing System.IO;public class MenuTest : MonoBehaviour {& & // Add a menu item named \"Do Something\" to MyMenu in the menu bar.& & [MenuItem (\"MyMenu/Do Something\")]& & static void DoSomething () {& & & & Debug.Log (\"Doing Something...\");',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:0,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'算了,还是留几个字吧。',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}拒绝访问 |
| 百度云加速
请打开cookies.
此网站 () 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(3aad-ua98).
重新安装浏览器,或使用别的浏览器温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
Hierarchy窗口中是场景中的Game Object列表
Project窗口中是磁盘上Assets文件夹中的内容,可用来创建Game Object
调试用Debug.Log()或者print函数打日志
目前完全无法采用VisualStudio进行调试,只能用MonoDevelop。因Unity采用的是Mono运行时引擎而不是CLR,参考
另发现插件,Write and debug your Unity games inside Visual Studio
MonoDevelop对Unity的attach调试不能跨dll
Unity自带Mono版本可能是2.6
目前应谨慎考虑采用Mono写需长时间运行的服务器程序
MonoDevelop:
MonoDevelop写的源码文件会以UTF8 Unix结尾方式保存
Unity自带的MonoDevelop和官方MonoDevelop的有区别的,不要升级MonoDevelop
实用函数:
()可以切换场景
资源管理:
文件打包用的是
所有通过类加载的资源必须放在名为Resources的目录中
All assets that are in a folder named "Resources" anywhere in the Assets folder can be accessed via the
functions. Multiple "Resources" folders may exist and when loading objects each will be examined.
不同Resources目录同名目录加载规则无法预测!
,用的是直接COM读取excel的方式,没有参与资源管线
所有需要通过散包方式加载的文件必须通过的方式,加载后可自动识别movie、text、texture和bytes四种格式
,包括对已封装好的内部资源的加载和外部散包资源的加载
to center your automatic GUILayout
引用第三方库:
Unity支持(Platform Invocation Services)方式的插件,
团队工作:
编译与发布:
定制Build流程:
Unity发布的exe是非托管的,但逻辑dll是放在GAME_Data\Managed下的,代码完全可以反编译
没发现Unity编译后的资源目录Game_Data中的文件结构和编辑器中的Project目录有明显的直接对应关系
编译后资源都被放到sharedassets*.assets这样的加密文件中,其中*可能是场景编号; Scene文件可能被放到了level*中
Resources和其他目录不一样,其他目录编译完后会被自动打包合并,而Resources会有一个直接对应的resources.asset文件
相同的源反复编译生成的二进制不变
添加空场景后Game_Data/mainData发生改变
prefab和各种资源关联啥的会自动处理的,只把用到的打包
编辑器中Import Package但没有真正使用不会对编译结果造成影响
Game.exe始终是稳定不变的
版本管理:
即使采用了Force Text选项,ProjectSettings下很多asset文件也还是二进制格式的
WebBrowser相关:
可通过方法调用浏览器js方法
Unity doesn't support vector fonts. For every font size that you want to support, you need to import a new version of the font and change its import settings to a different size. @Unity 3.x Game Development by Exple Beginner's Guide[P201]
,其中shader开放可免费使用
采用双色半圆拼接饼状图是个技巧
(不断更新中)
(仅限于MonoBehaviour子类)
Inherit from
function to do initialisation
The class name must match the file name
Coroutines have a different syntax in C#
Coroutines have to have a return type of IEnumerator and you yield using "yield return" instead of just "yield"
Don't use namespaces
Only member variables are serialized and are shown in the Inspector
Avoid using the constructor or variable initializers
Never initialize any values in the constructor or variable initializers in a MonoBehaviour script. Instead use Awake or Start for this purpose.
AssertBundle
Editor扩展脚本:
Editor脚本是可以用C#写的,编译完后重启Unity生效
不要在Editor脚本中采用中文菜单,有一定可能down机
如果乱码,需要将文件保存为UTF8格式
压缩方式用的是lzma
,这个对版本制作有用
版本控制:
,哪些文件该放到svn的问题解决
Unity目前的版本已经把需要svn控制的文件单独归类放到Project Settings里了,现在只需要将Assets和ProjectSettings两目录加入svn即可&@
必须进行以下设置才可将项目加入到svn管理:
meta文件为Unity内部使用,不要手工更改,也必须加入svn
Unity内部是用GUID做文件间引用的
Force Text可以将场景文件序列化为文本,以利于版本控制,默认为二进制
Unity资源序列化采用的是
中文教程:&
中文教程:&
相同Depth的控件会存在z排序不稳定问题!复杂界面要进行合理的规划
Unity引用第三方dll随便拖到项目任何目录就可以了
所引用的托管dll必须是net3.5版本以下的(包括)
如果托管dll依赖非托管dll,则pc standalone版本的可行,web版的有安全限制,移动版也不可行,甚至System.IO名字空间都是受限的
要采用net20版本的,不要用mono版的,据说有坑
微端构造AssetBundle的时候不加BuildAssetBundleOptions.DeterministicAssetBundle选项,两次出来的md5码就不一样
将扩充代码放到单独目录中用VS开发,这样就可以加UnitTest了
运行时会将日志输出去到Data目录下的output_log.txt文件(UTF8),省的自己写日志文件了
不要打开GAME.sln,而要打开GAME-csharp.sln,可同时由MonoDevelop和VisualStudio编辑
调整项目Build Settings后,则可在MonoDevelop/Run/Attach to Process窗口中找到正在运行的游戏以进行attach调试
protobuf编解码在Unity Editor中运行正常,但单独部署运行抛出TypeInitializationException的问题
如果发现Unity Editor中运行正常而单独运行时不正常,可以考虑将Api Compatibility Level改为.NET 2.0而不是其Subset
Hightmap Resolution会比Terrain Resolution大1
移动平台小地形最好用模型,或者将Unity自带的Terrain用插件导出为模型,省性能。Unity Terrain依赖shader 2.0,某些手机不支持,即使导出地图也依赖shader 2.0,自己做地形模型一张贴图即可搞定
Skybox的设置在Edit/RenderSettings/Skybox Material下,确保Game Overlay按钮选中才可以显示出来
要第三人称在场景中漫游,需要将First Person Controller加入到场景
Inspector窗口中的Static Checkbox: Checking this box tells Unity that a particular object in your scene will not be moving during the game, and as such can be lightmapped.
支持,整合了,支持P2P,还提供了房间服务器和NAT穿透服务器,搞不定还有代理服务器。开房间娱乐性质的游戏不用写服务器逻辑
Anything that uses Rigidbodies or realistic movement should use FixedUpdate, but instead of Update for every frame.
Unity-4.0.1f2尚不支持Win8-Metro/WinPhone的导出
动态下载和加载资源:
Web MMO需要尽量减少首次下载量,并能在游戏运行中动态加载资源
游戏运行时资源下载和加载,Unity Pro支持两种方法: 资源包和资源目录。非Pro版本智能使用资源目录方法。一个资源包是一个外部的资源集合,游戏中可以使用多个资源包,资源包是在发行版本以外存在的。资源目录是一些资源的集合,资源目录被包含在发行版本里面,但是并没有和任何游戏对象有关联。资源目录通过Edit-&Project Settings-&Player的First Streamed Level With Resource来设定
对Web MMO产品的建议
主要是资源大小的考虑,资源中,贴图是大头,需要尽量减少贴图使用量。卡通类游戏比较适合
由于动态下载和加载资源会一直存在,玩家角色在场景中的移动速度不宜过大,大场景不宜频繁切换。资源动态下载需要占用玩家一定网络带宽
使用Unity的准备工作:
Unity毕竟是一款包含内容和功能很多的游戏引擎。需要花一些时间熟悉其编辑器、代码和开发环境、资源生产流程等主要功能。不建议项目开始前没有一定的准备期
,非常给力的一组学习笔记
unity的主要使用者是关卡策划和程序员
目前Unity对中文的支持不是很好,因此在Unity中尽量不要使用中文,防止出现各种各样莫名其妙的异常
如何调整太阳光方向和天空盒太阳贴图方向一致?
首先在设计视图中拖动视角,让镜头中心对准天空盒上的太阳
然后在渲染设置中临时将天空盒设置为无(为了方便调整Sun的角度,否则天空盒太亮看不清楚)
然后选中Sun并使用旋转工具(快捷键E),将光线的方向正对自己
然后再将天空盒恢复即可
一个好的游戏没有好的配乐和音效,就好像无暇的水晶缺少了灯光的陪衬。而音乐不仅能渲染出玩家攻略游戏时的氛围,还能增加提高玩家对游戏的认知度 @
所有Prefab实例的属性都引用自Prefab的预设,当预设属性改变时,对应的实例属性也会相应改变。但当实例的某个属性被手工调整后,即使修改预设的属性值,该值也会以手工调整的值为准
随着360和Unity的合作,前者的360安全浏览器预装Unity3d的方案实施会给Unity进军中国市场带来可观的便捷
Choosing GUI framework for your Unity3D project: EZGUI vs NGUI,
Directional light的Shadow Type:
No Shadows
Hard Shadow - 影子的轮廓比较清晰
Soft Shadow - 影子边缘模糊一点,更加逼真
Particle Emitter: 只管发射粒子
Particle Animator: 粒子动画器,负责对发射器产生的粒子进行二次加工,比如使粒子的颜色不断的变化,缩放粒子等
Particle Renderer: 粒子渲染器,负责将粒子渲染到游戏中,并且可以决定粒子的材质、光影等
当选中Prefab的实例时,检视面板上就会显示预制对象菜单:
Select:在工程面板中快速选取该实例引用的预制
Revert:将实例修改过的参数全部还原为预制的参数
Apply:将实例修改过的参数全部应用到预制,此时所有引用此预制的实例会一起受到影响而变动
yield用法:
所有使用yield的函数必须返回IEnumerator类型(这点和C# IEnumerable标准用法有差异!)
所有IEnumerator类型函数必须使用”StartCoroutine”这个函数触发,不能单独使用
不同颜色的字体需要创建不同的Materials, 其贴图设置为字体贴图, Shader要采用GUI/TextShader
只有public field才可进入Inspector窗口, 该功能可用[]特性屏蔽
和Inspector窗口关联的public field重命名后Inspector中编辑的值会丢失!
Be aware that any value adjusted in the Inspector will override the original value given to a variable within the script. It will not rewrite the value stated in the script, but simply replaces it when the game runs.? You can also revert to the values declared in the script by clicking on the Cog icon to the right of the component and choosing Reset from the drop-down menu that appears.
public property不会进入Instactor
enum在Inspector中会自动展示为ComboBox
动态调用, 解耦神器:
可通过方法进行动态方法调用!
可采用/方法, 用字符串名称的方式直接查找对象
将Prefab直接拖入场景可进行查看
, unity官方并未提供引擎dll对应的xml文档, 这对VisualStudio下的自动提示不友好
WCF & Unity
Service References的代码可用VisualStudio自带的“添加服务引用”功能,没必要非命令行用mono的svcutil。成功生成后需要将对应的C#代码文件拷贝到Assert下合适的目录中,否则不会参加编译
需要从C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0拷贝到*\Assets\Plugins下的dll有:
System.Runtime.Serialization.dll
System.Security.dll
System.ServiceModel.dll
System.IdentityModel.Selectors.dll // 该文件也是必要的,否则System.ServiceModel.dll不会被正确引入
Unity会自动生成的两种项目文件,*-csharp.sln/*-vs.csproj或*.sln/*.csproj,前者是供VS用的,后者是供MonoDevelop用的,包含了自定义的项目类型*.unityproj
不要手工向*-csharp.sln中加入任何project,这会在Unity重新生成后覆盖。可将sln另存为得以解决
调整NGUI“米老鼠”大小:
is a gui and command line tool to create sprite sheets or sprite atlases
,包括cocos2d、CEGUI、Unity等,还可方便自定义输出格式
unity双开:
暂没有内嵌浏览器的支持
,将会在随后的unity新版中得到支持
GUI库,在移动平台会遇到性能问题,但开发效率要比NGUI高
阅读(30336)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_081071',
blogTitle:'Unity 3D 学习笔记',
blogAbstract:'&
Hierarchy窗口中是场景中的Game Object列表
Project窗口中是磁盘上Assets文件夹中的内容,可用来创建Game Object
调试用Debug.Log()或者print函数打日志
目前完全无法采用VisualStudio进行调试,只能用MonoDevelop。因Unity采用的是Mono运行时引擎而不是CLR,参考'
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 unity log 输出到屏幕 的文章

 

随机推荐