123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import { Node, Prefab, instantiate, resources } from "cc";
- export class uiManager {
- private static instance:uiManager =null;
- public static Instance(){
- if(this.instance==null){
- this.instance = new uiManager
- }
- return this.instance
- }
- private ui_parent:Node = null
- private loading_view:Node = null
- private send_msg_view:Node = null
- public init(ui_node:Node,loading_node:Node,send_msg_loading:Node){
- this.ui_parent = ui_node
- this.send_msg_view = send_msg_loading
- this.loading_view = loading_node
- }
- public showUi(ui_path:string,parent:Node =null,cb=null){
- if(this.ui_parent==null){
- return console.error("ui_parent not init..")
- }
- resources.load(ui_path,Prefab,(err,fb:Prefab)=>{
- if(!err){
- let node = instantiate(fb)
- if(parent!=null){
- node.parent = parent
- }else{
- node.parent = this.ui_parent
- }
- if(cb!=null){
- cb(node)
- }
- }else{
- console.error("showUi error:",err)
- }
- })
- }
- public showLoading(){
- if(this.loading_view!=null){
- }else{
- console.error("loading view not init..")
- }
- }
- public hideLoading(){
- if(this.loading_view!=null){
-
- }else{
- console.error("loading view not init..")
- }
- }
- public showSendMsgWait(){
- if(this.send_msg_view!=null){
- this.send_msg_view.active = true
- }else{
- console.error("send_msg_view view not init..")
- }
- }
- public hideSendMsgWait(){
- if(this.send_msg_view!=null){
- this.send_msg_view.active = false
- }else{
- console.error("send_msg_view view not init..")
- }
- }
- public onButtonListen(btn:Node,call_back){
- btn.on(Node.EventType.TOUCH_END,()=>{
- call_back()
- })
- }
- }
|