void Awake() { _ins = this; MessageQueue = new Queue <Tuple <string, int> >(); //pToast = GameObjectExtension.InstantiateFromPacket("ui_toast", "Toast", root.gameObject); //var iToast = Instantiate(pToast, root) as GameObject; var iToast = GameObjectExtension.InstantiateFromPacket("ui_toast", "Toast", root.gameObject); iToast.transform.localPosition = position; iToast.transform.localScale = Vector3.one; wToast = iToast.GetComponent <UIWidget>(); wToast.color = new Color(wToast.color.r, wToast.color.g, wToast.color.b, 0); Queue_sq = DOTween.Sequence(); Queue_sq.SetAutoKill(false).SetRecyclable(true); Queue_splashTweener = DOTween.ToAlpha(() => wToast.color, color => wToast.color = color, 1, 0.35f); Queue_fadeTweener = DOTween.ToAlpha(() => wToast.color, color => wToast.color = color, 0, 0.35f); Queue_splashTweener.SetRecyclable(true); Queue_fadeTweener.SetRecyclable(true); Queue_sq.Append(Queue_splashTweener); Queue_sq.AppendInterval(Queue_TimeInterval); Queue_sq.Append(Queue_fadeTweener); Queue_sq.AppendCallback(checkQueue); Queue_sq.TogglePause(); }
public IEnumerator Init() { //初始化romcfg GameObject wndConfig = GameObjectExtension.InstantiateFromPacket("rom_share", "WndConfig", null); GameObject.DontDestroyOnLoad(wndConfig); yield break; }
/////////////////结束///////////////// public void GetUIPrefab(string assetName, GameObject parent, LuaTable luaTable, LuaFunction luaCallBack) { if (mResManager == null) { return; } GameObject go = GameObjectExtension.InstantiateFromPacket(assetName, assetName + ".prefab", parent); go.name = assetName; go.layer = LayerMask.NameToLayer("UI"); go.transform.SetParent(parent.transform, false); LuaBehaviour tmpBehaviour = go.AddComponent <LuaBehaviour>(); tmpBehaviour.Init(luaTable); if (luaCallBack != null) { luaCallBack.BeginPCall(); luaCallBack.Push(go); luaCallBack.PCall(); luaCallBack.EndPCall(); } //Debug.Log("CreatePanel::>> " + assetName + " " + prefab); //mUIList.Add(go); //mResManager.LoadPrefab("pack_res/ui_login", "ui_login", delegate(UnityEngine.Object[] objs) // { // if (objs.Length == 0) return; // GameObject prefab = objs[0] as GameObject; // if (prefab == null) // { // return; // } // GameObject go = UnityEngine.GameObject.Instantiate(prefab) as GameObject; // go.name = assetName; // go.layer = LayerMask.NameToLayer("UI"); //go.transform.SetParent(parent, false); // LuaBehaviour tmpBehaviour = go.AddComponent<LuaBehaviour>(); // tmpBehaviour.Init(luaTable); // if (luaCallBack != null) // { // luaCallBack.BeginPCall(); // luaCallBack.Push(go); // luaCallBack.PCall(); // luaCallBack.EndPCall(); // } // Debug.Log("CreatePanel::>> " + assetName + " " + prefab); // //mUIList.Add(go); // }); }
public IEnumerator Init() { MonoEX.Debug.LogoutHandle = MonoEXLogout;//设定日志输出回调 //初始化数据表管理器 new TabReaderManage(new U3dTabFactory()); //挂载协程管理组件 CoroutineManage.AutoInstance(); yield return(null);//等待携程管理器初始化完成 //资源引用管理器 //new ResourceRefManage(); //挂载TimeLine组件 UROMSystem.Single.AddComponent <UTimeLine>(); //挂载场景管理组件 //UROMSystem.Single.AddComponent<SceneManage>(); //挂载UI景深渲染组件 /* * GameObject UIForegroundCameraObj = GameObject.Find("/UIRoot/UICameras/Camera_UIForeground"); * UIForegroundScreenTexture cmUIForegroundScreenTexture = UIForegroundCameraObj.AddComponent<UIForegroundScreenTexture>(); * cmUIForegroundScreenTexture.m_camera = UIForegroundCameraObj.GetComponent<Camera>(); * cmUIForegroundScreenTexture.m_targetUITexture = GameObject.Find("/UIRoot/UIForegroundLayer/UIForegroundTexture"); */ //装载rom资源 { List <string> packs = new List <string>(); packs.Add("packets"); packs.Add("rom_upd"); //更新界面所需要资源 packs.Add("rom_share"); //更新界面和逻辑公共资源 PacketLoader loader = new PacketLoader(); loader.Start(PackType.Res, packs, null); //等待资源装载完成 while (loader.Result == PacketLoader.ResultEnum.Loading) { yield return(null); } } //初始化romcfg GameObject gameConfig = GameObjectExtension.InstantiateFromPacket("rom_share", "GameConfig", null); GameObject.DontDestroyOnLoad(gameConfig); yield return(null); }
///// <summary> ///// 当绘制单位时设置shader ///// TODO 解决加载单位没有shader问题 ///// </summary> //private void OnWillRenderObject() //{ // if (!isSetShader) // { // isSetShader = true; // var rander = GetComponent<Renderer>(); // if (rander != null) // { // var core = PacketManage.Single.GetPacket("core"); // if (core != null) // { // var shader = core.Load("Avatar_N.shader") as Shader; // if (shader != null) // { // rander.material.shader = shader; // } // } // } // } //} /// <summary> /// 加载 /// </summary> private void LoadSource() { NowWorldCamera = GameObject.Find("/PTZCamera/SceneryCamera").GetComponent <Camera>(); Head = transform.Find("head").gameObject.transform; GameObject parent = GameObject.Find("ui_fightU/bloodParent"); bloodBar = GameObjectExtension.InstantiateFromPacket("ui_fightu", "blood.prefab", parent).transform; bloodBar.localPosition = Vector3.zero; bloodBar.localScale = Vector3.one; bloodBarCom = bloodBar.gameObject.AddComponent <BloodBar>(); //ModelRander = gameObject.GetComponent<MFAModelRender>(); }
public void popToast(string messageToShow, TweenCallback callback) { /** * 遍历数组中的旧消息,并使它们都做向上移动的动画 **/ int i = tail; while (i != head) { if (circleTable[i].Item1.IsPlaying()) { var moveY = circleTable[i].Item2.GetComponent <UIWidget>().height; var ToastPosition = circleTable[i].Item2.transform.position; circleTable[i].Item1.Join(circleTable[i].Item2.transform.DOBlendableLocalMoveBy( new Vector3(0, moveY, 0), 0.2f, true)); } i = (i + 1 + LIMIT) % LIMIT; } //var iToast = Instantiate(pToast, root) as GameObject; GameObject iToast = GameObjectExtension.InstantiateFromPacket("ui_toast", "Toast", root.gameObject); iToast.name = head.ToString(); iToast.transform.localPosition = position; iToast.transform.localScale = Vector3.one; iToast.GetComponentInChildren <UILabel>().text = messageToShow; iToast.GetComponentInChildren <UILabel>().AssumeNaturalSize(); iToast.GetComponentInChildren <UISprite>().width = iToast.GetComponentInChildren <UILabel>().width + 80; var iWidget = iToast.GetComponent <UIWidget>(); iWidget.alpha = 0; var sq = DOTween.Sequence(); var Upwards_splashTweener = DOTween.ToAlpha(() => iWidget.color, color => iWidget.color = color, 1, 0.5f); var Upwards_fadeTweener = DOTween.ToAlpha(() => iWidget.color, color => iWidget.color = color, 0, 0.35f); sq.Append(Upwards_splashTweener); sq.AppendInterval(Upwards_TimeInterval); sq.Append(Upwards_fadeTweener); //动画完成时,使队尾索引向后移动 callback += () => { tail = (tail + 1 + LIMIT) % LIMIT; Destroy(iToast); }; sq.AppendCallback(callback); //队头索引向后移动 circleTable[(head + LIMIT) % LIMIT] = Tuple.Create(sq, iToast); head = (head + 1 + LIMIT) % LIMIT; //当队头索引将要覆盖队尾时,让队尾元素提前完成逻辑并向前移动 if ((head + LIMIT) % LIMIT == tail) { circleTable[tail].Item1.Complete(true); } }
/// <summary> /// 目标受到伤害或者加血等的血条上的文字效果 /// </summary> /// <param name="packer">生命值变更包装类</param> public static void ShowHurtNum(FightManager.HealthChangePacker packer) { if (packer.ObjType == ObjectID.ObjectType.MyJiDi || packer.ObjType == ObjectID.ObjectType.EnemyJiDi) { Tools.CallMethod("userInfo_controller", "changeJiDiHP", (int)packer.ObjType, packer.CurrentHp, packer.TotalHp); } else { int hurtNum_int = (int)packer.ChangeValue; BloodBar mgo = packer.GameObj.GetComponent <RanderControl>().bloodBarCom; Transform deltaHP = GameObjectExtension.InstantiateFromPacket("ui_fightu", "deltaHP.prefab", mgo.gameObject).transform; deltaHP.localPosition = new Vector3(Random.value * 50 - 25, -Random.value * 20, 0); EventDelegate _event = new EventDelegate(mgo, "DestroyDeltaHP"); _event.parameters[0] = new EventDelegate.Parameter(deltaHP); deltaHP.GetChild(0).GetComponent <TweenPosition>().AddOnFinished(_event); switch (packer.HurtType) { case FightManager.HurtType.NormalAttack: //普通 deltaHP.GetChild(0).GetComponent <UISprite>().spriteName = null; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().color = Color.white; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().text = "" + hurtNum_int; break; case FightManager.HurtType.Crit: //暴击 deltaHP.GetChild(0).GetComponent <UISprite>().spriteName = "zhandou_yuan_xuanzhong"; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().color = Color.red; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().text = "" + hurtNum_int; break; case FightManager.HurtType.SkillAttack: //技能 deltaHP.GetChild(0).GetComponent <UISprite>().spriteName = null; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().color = Color.blue; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().text = "" + hurtNum_int; break; case FightManager.HurtType.Miss: //miss deltaHP.GetChild(0).GetComponent <UISprite>().spriteName = null; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().color = Color.gray; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().text = "miss"; break; case FightManager.HurtType.Cure: //治疗 deltaHP.GetChild(0).GetComponent <UISprite>().spriteName = null; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().color = Color.green; deltaHP.GetChild(0).GetChild(0).GetComponent <UILabel>().text = "+" + hurtNum_int; break; } } }
static int InstantiateFromPacket(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); string arg0 = ToLua.CheckString(L, 1); string arg1 = ToLua.CheckString(L, 2); UnityEngine.GameObject arg2 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 3, typeof(UnityEngine.GameObject)); UnityEngine.GameObject o = GameObjectExtension.InstantiateFromPacket(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
IEnumerator coDoCmd() { while (m_Cmds.Count > 0) { var aInfo = m_Cmds[0]; m_Cmds.RemoveAt(0); var wndName = aInfo.name; var subID = ""; string[] sArray = aInfo.name.Split('&'); if (sArray.Length == 2) { wndName = sArray[0]; subID = '&' + sArray[1]; } if (!m_wndInfos.ContainsKey(aInfo.name)) { if (sArray.Length == 2) { wndInfo wInfo2 = (wndInfo)m_wndInfos[wndName].Clone(); wInfo2.name = aInfo.name; m_wndInfos.Add(wInfo2.name, wInfo2); } else { Debug.LogError("窗体注册信息不存在 " + wndName); continue; } } if (aInfo.needVisible != WShowType.hide && aInfo.needVisible != WShowType.destroy) { //标记是否第一次打开(包括释放后再打开) bool isFirstShow = false; //从最近隐藏记录中清除 if (m_wndLastHideTime.ContainsKey(wndName + subID)) { m_wndLastHideTime.Remove(wndName + subID); } isFirstShow = !m_wndInstances.ContainsKey(wndName + subID); //窗体不存在,则创建 if (isFirstShow) { IEnumerator it = LoadDepend(wndName); while (it.MoveNext()) { yield return(null); } wndInfo wInfo = m_wndInfos[wndName + subID]; //创建一个uipanel GameObject uipanel = new GameObject(wInfo.name + "_panel"); uipanel.transform.parent = UIRootObj.transform; uipanel.transform.localScale = new Vector3(1, 1, 1); uipanel.transform.localRotation = new Quaternion(0, 0, 0, 1); uipanel.transform.localPosition = new Vector3(0, 0, 0); uipanel.layer = LayerMask.NameToLayer("UI");//设置层 UIPanel cmpanel = uipanel.AddComponent <UIPanel>(); GameObject wnd_Obj = GameObjectExtension.InstantiateFromPacket(wInfo.dependPackets[1], wndName + ".prefab", uipanel); if (wnd_Obj == null) { //删除刚创建的uipanel GameObject.Destroy(uipanel); Debug.LogError(String.Format("实例化窗体错误, packet:{0} wndName:{1}", wInfo.dependPackets[1], wInfo.name)); throw new Exception(); } //设置新创建的panel锚点 { UIRect rectCM = uipanel.GetComponent <UIRect>(); rectCM.SetAnchor(UIRootObj, 0, 0, 0, 0); rectCM.updateAnchors = UIRect.AnchorUpdate.OnStart; } //设置预置锚点 const int safev = 1; { UIRect rectCM = wnd_Obj.GetComponent <UIRect>(); rectCM.SetAnchor(uipanel, -safev, -safev, safev, safev); rectCM.updateAnchors = UIRect.AnchorUpdate.OnStart; } //创建挡板 GameObject uibaffle; { uibaffle = new GameObject(wInfo.name + "_baffle"); uibaffle.layer = LayerMask.NameToLayer("UI");//设置层 uibaffle.transform.parent = uipanel.transform; uibaffle.transform.localScale = Vector3.one; uibaffle.transform.localRotation = Quaternion.identity; uibaffle.transform.localPosition = Vector3.zero; //增加碰撞盒 var cl = uibaffle.AddComponent <BoxCollider>(); //增加UIWidget组件 var cmBaffleWidget = uibaffle.AddComponent <UIWidget>(); cl.isTrigger = true; cmBaffleWidget.autoResizeBoxCollider = true; cmBaffleWidget.updateAnchors = UIRect.AnchorUpdate.OnStart; cmBaffleWidget.SetAnchor(uipanel, -safev, -safev, safev, safev);//设置锚点 cmBaffleWidget.depth = -99; } wnd_Obj.name = wndName + subID; wnd_Obj.SetActive(true); uipanel.SetActive(false); m_wndInstances.Add(wndName + subID, new Wnd(uipanel, uibaffle, wInfo)); if (aInfo.isWithBg)//再加一个gameobject的原因是如果做动画底板需要层级高于预制,底板会压在预制上 { //TODODO 图片放到了Resources目录 UITexture ut = NGUITools.AddWidget <UITexture>(uipanel, -99); Texture texure = Resources.Load <Texture>("zanting_jiashenceng"); ut.mainTexture = texure; UIStretch stretch = ut.gameObject.AddComponent <UIStretch>(); stretch.style = UIStretch.Style.Both; // set relative size bigger stretch.relativeSize = new Vector2(3, 3); } } //显示 Wnd wnd = m_wndInstances[wndName + subID]; if (aInfo.needVisible == WShowType.preLoad) { yield return(null); Wnd.OnPreLoadFinish.Call(wnd); } else if (aInfo.needVisible == WShowType.show) { wnd._Show(aInfo.duration); //等待窗体组件准备就绪 yield return(null); if (isFirstShow) { Wnd.OnShowFinish.Call(wnd); } else { Wnd.OnReOpenWnd.Call(wnd); } if (OnWndOpen != null) { OnWndOpen.Call(wndName); } } } else { if (m_wndInstances.ContainsKey(wndName + subID)) { //从最近隐藏记录中清除 if (aInfo.needVisible == WShowType.destroy && m_wndLastHideTime.ContainsKey(wndName + subID)) { m_wndLastHideTime.Remove(wndName + subID); } Wnd wnd = m_wndInstances[wndName + subID]; wnd._Hide(aInfo.duration, aInfo.needVisible, aInfo.PlantfromDetph); if (aInfo.needVisible == WShowType.hide) { Wnd.OnHideFinish.Call(wnd); } else if (aInfo.needVisible == WShowType.destroy) { Wnd.OnDestroyFinish.Call(wnd); } } } yield return(null); } m_coIsRuning = false; }
/// <summary> /// 加载Ab包资源 /// </summary> /// <param name="key"></param> /// <param name="package"></param> /// <returns></returns> public GameObject Load(string key, string package) { return(GameObjectExtension.InstantiateFromPacket(package, key, null)); }