几段代码
来源:互联网 发布:c 连接access数据库 编辑:程序博客网 时间:2024/04/30 03:50
/// <summary>/// Determines whether the 'parent' contains a 'child' in its hierarchy./// </summary>static public bool IsChild (Transform parent, Transform child){if (parent == null || child == null) return false;while (child != null){if (child == parent) return true;child = child.parent;}return false;}
/// <summary>/// Recursively set the game object's layer./// </summary>static public void SetLayer (GameObject go, int layer){go.layer = layer;Transform t = go.transform;for (int i = 0, imax = t.childCount; i < imax; ++i){Transform child = t.GetChild(i);SetLayer(child.gameObject, layer);}}
/// <summary>/// Make the specified selection pixel-perfect./// </summary>static public void MakePixelPerfect (Transform t){UIWidget w = t.GetComponent<UIWidget>();if (w != null){w.MakePixelPerfect();}else{t.localPosition = Round(t.localPosition);t.localScale = Round(t.localScale);for (int i = 0, imax = t.childCount; i < imax; ++i){MakePixelPerfect(t.GetChild(i));}}}
文件
/// <summary>/// Save the specified binary data into the specified file./// </summary>static public bool Save (string fileName, byte[] bytes){#if UNITY_WEBPLAYER || UNITY_FLASH || UNITY_METROreturn false;#elseif (!NGUITools.fileAccess) return false;string path = Application.persistentDataPath + "/" + fileName;if (bytes == null){if (File.Exists(path)) File.Delete(path);return true;}FileStream file = null;try{file = File.Create(path);}catch (System.Exception ex){NGUIDebug.Log(ex.Message);return false;}file.Write(bytes, 0, bytes.Length);file.Close();return true;#endif}/// <summary>/// Load all binary data from the specified file./// </summary>static public byte[] Load (string fileName){#if UNITY_WEBPLAYER || UNITY_FLASH || UNITY_METROreturn null;#elseif (!NGUITools.fileAccess) return null;string path = Application.persistentDataPath + "/" + fileName;if (File.Exists(path)){return File.ReadAllBytes(path);}return null;#endif}
/// <summary>/// Pre-multiply shaders result in a black outline if this operation is done in the shader. It's better to do it outside./// </summary>static public Color ApplyPMA (Color c){if (c.a != 1f){c.r *= c.a;c.g *= c.a;c.b *= c.a;}return c;}
剪切板
/// <summary>/// Access to the clipboard via a hacky method of accessing Unity's internals. Won't work in the web player./// </summary>public static string clipboard{get{PropertyInfo copyBuffer = GetSystemCopyBufferProperty();return (copyBuffer != null) ? (string)copyBuffer.GetValue(null, null) : null;}set{PropertyInfo copyBuffer = GetSystemCopyBufferProperty();if (copyBuffer != null) copyBuffer.SetValue(null, value, null);}}#endif}
Sprite
/// <summary>/// Add a sprite appropriate for the specified atlas sprite./// It will be sliced if the sprite has an inner rect, and a regular sprite otherwise./// </summary>static public UISprite AddSprite (GameObject go, UIAtlas atlas, string spriteName){UIAtlas.Sprite sp = (atlas != null) ? atlas.GetSprite(spriteName) : null;UISprite sprite = AddWidget<UISprite>(go);sprite.type = (sp == null || sp.inner == sp.outer) ? UISprite.Type.Simple : UISprite.Type.Sliced;sprite.atlas = atlas;sprite.spriteName = spriteName;return sprite;}
/// <summary>/// Add a new widget of specified type./// </summary>static public T AddWidget<T> (GameObject go) where T : UIWidget{int depth = CalculateNextDepth(go);// Create the widget and place it above other widgetsT widget = AddChild<T>(go);widget.depth = depth;// Clear the local transformTransform t = widget.transform;t.localPosition = Vector3.zero;t.localRotation = Quaternion.identity;t.localScale = new Vector3(100f, 100f, 1f);widget.gameObject.layer = go.layer;return widget;}
0 0
- 几段C#代码
- 几段代码
- 几段代码2
- Extjs 的几段代码
- C#连接数据库几段代码-加注
- PHP 处理字符串的几段代码
- 几段重要的代码(1)
- 今天上机测试了几段代码
- 几段经典的js代码解析
- 简单几段代码实现窗口抖动
- 几段关于const的代码
- 几段PHP 数组操作代码
- 内存空间分几部分:代码段、数据段,栈,堆
- C++中操作数据库的几段代码
- ASP.NET中,几段播放器的代码
- 初学者学习PHP开发应该掌握几段精华代码
- nginx 服务器端配置可以重用的几段代码
- 初学者学习PHP开发应该掌握几段精华代码
- Html的空格显示
- Palindrome Number
- ZOJ 3228 Searching the String(AC自动机)
- asp多重条件,如果符合a则输出b,如果答c,则输出2
- 常用的vim插件及vimrc备份
- 几段代码
- javascript动画、运动算法详细解释与分析
- Theano学习四----Theano shared
- 【深入浅出Objective-C】8.4数据(NSData)和8.5数字(NSNumber)
- 研究了下FBX Sdk小记录
- hdu 2196 树形dp经典题目
- ajax json格式数据的获取(一)
- 性能调优指南--计算机系统Java应用程序V0.1
- 新年愿望