zoukankan      html  css  js  c++  java
  • NGUI底层函数总结一

    1、实现sprite动画组件:UISpriteAnimation 
    2、控制动画播放类:ActiveAnimation类 
    方法:static public ActiveAnimation Play (Animation anim, string clipName, Direction playDirection, 
    EnableCondition enableBeforePlay, DisableCondition disableCondition) 
    3、将镜头内所见转换成rendertexcture的方法:NGUIEditorExtensions.RenderToTexture 
    4、editor界面编辑空格GUILayout.Space(6f) 
    5、绘制属性框NGUIEditorTools.DrawProperty(serializedObject, “charsPerSecond”); 
    6、绘制时间框NGUIEditorTools.DrawEvents(“On Finished”, tw, tw.onFinished); 
    7、告知unity标记prefab属性以改变UnityEditor.EditorUtility.SetDirty(obj); 
    8、NGUIMath封装了很多有用的方法: 
    (1)static public float Lerp (float from, float to, float factor) 
    获取浮点插值 
    (2)static public int ClampIndex (int val, int max) 
    判断是否在0到最大数区间内 
    (3)static public float WrapAngle (float angle) 
    转换函数到-180到180度之间 
    (4)static public int HexToDecimal (char ch) 
    将字符串转换成十六进制 
    (5)static public char DecimalToHexChar (int num) 
    将0到16转成哈希值 
    (6)static public int ColorToInt (Color c) 
    颜色转成rgba32 
    (7)static public Color IntToColor (int val) 
    rgba32转成颜色 
    (8)static public string IntToBinary (int val, int bits) 
    int ,十进制转成二进制 
    (9)static public Bounds CalculateAbsoluteWidgetBounds (Transform trans) 
    计算当前transform下面的边界框 
    (10)static float DistancePointToLineSegment (Vector2 point, Vector2 a, Vector2 b) 
    返回点到线的距离 
    9、NGUITools也有很多有用的方法 
    (1)static public AudioSource PlaySound (AudioClip clip) 
    播放音频文件 
    (2)static public int RandomRange (int min, int max) 返回随机数 ,和UnityEngine.Random.Range()最大的区别就是可以包含最大数,当前unity自带这个如果最小数和最大数相等也可以返回最大数 
    (3)static public string GetHierarchy (GameObject obj) 
    返回当前节点的string路径 
    (4)static public T[] FindActive () where T : Component 
    查找当前节点下所有激活的组件 
    (5)static public Camera FindCameraForLayer (int layer) 
    找到当前层级下的渲染相机 
    (6)static public string GetTypeName () 
    返回当前方法名 
    (7)static public int AdjustDepth (GameObject Go, int adjustment) 
    适应当前某一个物体的深度 
    (8)static public void BringForward (GameObject go) 
    将当前组件置顶 
    (9)static public void PushBack (GameObject go) 
    将当前组件放置最后 
    (10)static public UIPanel CreateUI (Transform trans, bool advanced3D, int layer) 
    创建一个包含UIRoot的ui 
    (11)static public void SetChildLayer (this Transform t, int layer) 
    设置物体tramsform的层级 
    (12)static public UISprite AddSprite (this GameObject go, UIAtlas atlas, string spriteName, int depth = int.MaxValue)给某个物体添加uisprite 
    (13)static public GameObject GetRoot (GameObject go) 
    获取当前物体的根节点物体 
    (14)static public T FindInParents (GameObject go) where T : Component 
    找到当前物体的父节点中是否有该组件 
    (15)static public void Destroy (UnityEngine.Object obj) 
    销毁object 
    (16)static public void Broadcast (string funcName) 
    广播指定方法名 
    (17)static public void Broadcast (string funcName, object param) 
    广播指定方法 和参数 
    (18)static public bool IsChild (Transform parent, Transform child) 
    判断某个物体是指定物体的子物体 
    (19)static public bool GetActive (Behaviour mb)判断当前某个behaviour是否是激活状态 
    (20)static public void SetActive (GameObject go, bool state, bool compatibilityMode) 
    设置指定物体 (可选包含子物体)的active状态 
    (21)static public void SetLayer (GameObject go, int layer) 
    设置层级 
    (22)static public void MakePixelPerfect (Transform t) 
    设置物体组件 snap 呈现 
    (23)static public void FitOnScreen (this Camera cam, Transform transform, Transform content, Vector3 pos, out Bounds bounds) 
    设置ui完美显示的范围 
    (24)static public bool Save (string fileName, byte[] bytes) 
    保存指定内容的文件 
    (25)static public byte[] Load (string fileName) 
    读取指定文件 
    (26)static public void MarkParentAsChanged (GameObject go) 
    标记物体是否变化了 
    (27)static public T AddMissingComponent (this GameObject go) where T : Component 
    判断是否包含该组件,如果没有就新建一个,并返回该组件 
    (28)static public void Execute (GameObject go, string funcName) where T : Component 
    指定某个组件的指定方法 
    (29)static public void ExecuteAll (GameObject root, string funcName) where T : Component 
    执行包含子物体下的方法 
    (30)static public void ImmediatelyCreateDrawCalls (GameObject root) 
    直接执行所有的drawcall 
    (31) static public string KeyToCaption (KeyCode key) 
    转换keycode成string名称

     
    喜欢unity 和酷炫的效果。欢迎留言交流。
  • 相关阅读:
    k3 cloud套打模板中出现单元格数据为空的情况,及无法正确的选择数据源
    k3 cloud中列表字段汇总类型中设置了汇总以后没有显示出汇总值
    k3 cloud查看附件提示授予目录NetWorkService读写权限
    k3 cloud中提示总账期末结账提示过滤条件太长,请修改此过滤条件
    金蝶云k3 cloud采购入库单校验日期不通过
    C# Code First 配置(二)
    C# Azure 远程调试
    C# ABP源码详解 之 BackgroundJob,后台工作(一)
    C# 在webapi项目中配置Swagger(最新版2017)
    高并发之
  • 原文地址:https://www.cnblogs.com/smilejoi/p/6656375.html
Copyright © 2011-2022 走看看