public static void Init() { if (!isInit) { isInit = true; GameObject instance = GameObject.Find("UIManager"); if (instance == null) { instance = GameObjectManager.CreateGameObject("UIManager"); } UIManagerGo = instance; s_UILayerManager = instance.GetComponent <UILayerManager>(); s_UIAnimManager = instance.GetComponent <UIAnimManager>(); s_UIStackManager = instance.GetComponent <UIStackManager>(); s_EventSystem = instance.GetComponentInChildren <EventSystem>(); if (Application.isPlaying) { DontDestroyOnLoad(instance); } } }
public void Assign(SessionInterface defaultInterface) { MatchmakeUser matchedUser = defaultInterface as MatchmakeUser; GameObject newPlayer = gameObjectManager.CreateGameObject(matchedUser.Nickname, false); newPlayer.Tag = TAG.Character; UserGameObjectIndexes.Add(newPlayer.id); Scoreboard.AddNewEmptyPlayerScore(newPlayer.Name); UserSession userSession = new UserSession(); userSession.UserNickname = matchedUser.Nickname; userSession.TakeOver(matchedUser); userMediator.Add(userSession); UserInputProcess userInputProcess = newPlayer.AddComponent <UserInputProcess>(); userInputProcess.SetFence(this.mapCenter, this.mapHeight, this.mapWidth); //Console.WriteLine(matchedUser.Nickname + "이가 게임에 참가했습니다."); if (userMediator.GetSessionsCount() == Config.USER_COUNT_PER_ONE_GAME) { Start(); } }
static int CreateGameObject(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GameObject), typeof(UnityEngine.GameObject), typeof(bool))) { UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1); UnityEngine.GameObject arg1 = (UnityEngine.GameObject)ToLua.ToObject(L, 2); bool arg2 = LuaDLL.lua_toboolean(L, 3); UnityEngine.GameObject o = GameObjectManager.CreateGameObject(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(UnityEngine.GameObject), typeof(bool))) { string arg0 = ToLua.ToString(L, 1); UnityEngine.GameObject arg1 = (UnityEngine.GameObject)ToLua.ToObject(L, 2); bool arg2 = LuaDLL.lua_toboolean(L, 3); UnityEngine.GameObject o = GameObjectManager.CreateGameObject(arg0, arg1, arg2); ToLua.Push(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: GameObjectManager.CreateGameObject")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void UIManagerLoadTest() { //ResourcesConfigManager.Initialize(); GameObject manager = GameObjectManager.CreateGameObject("UIManager"); Assert.AreNotEqual(manager.GetComponent <UILayerManager>(), null); Assert.AreNotEqual(manager.GetComponent <UIAnimManager>(), null); Assert.AreNotEqual(manager.GetComponentInChildren <Camera>(), null); }
public override void Update(int deltaTime) { List <EntityBase> list = GetEntityList(); for (int i = 0; i < list.Count; i++) { if (!list[i].GetExistComp <PerfabComponent>()) { PerfabComponent comp = list[i].AddComp <PerfabComponent>(); comp.perfab = GameObjectManager.CreateGameObject(list[i].GetComp <AssetComponent>().m_assetName); } } }
public void ChangeModel(string modelName) { int layer = model.layer; GameObjectManager.DestroyGameObject(model); model = GameObjectManager.CreateGameObject(modelName); model.transform.SetParent(root.transform); model.transform.localPosition = new Vector3(0, 0, 0); model.transform.localEulerAngles = Vector3.zero; model.transform.localScale = Vector3.one; model.SetLayer(layer); }
public static GameObject Create(string prefabName, out RenderTexture tex) { GameObject temp0 = new GameObject("UIModelShow"); GameObject temp1 = new GameObject("Camera"); temp1.transform.SetParent(temp0.transform); temp1.transform.localPosition = new Vector3(0, 5000, 0); Camera ca = temp1.AddComponent <Camera>(); ca.clearFlags = CameraClearFlags.SolidColor; ca.backgroundColor = new Color(0, 0, 0, 5 / 255f); ca.orthographic = true; ca.orthographicSize = 0.72f; ca.depth = 100; ca.cullingMask = 1 << LayerMask.NameToLayer("UI"); GameObject root = new GameObject("Root"); root.transform.SetParent(temp1.transform); root.transform.localPosition = new Vector3(0, 0, 100); root.transform.eulerAngles = new Vector3(0, 180, 0); GameObject obj = GameObjectManager.CreateGameObject(prefabName); obj.transform.SetParent(root.transform); obj.transform.localPosition = new Vector3(0, 0, 0); obj.transform.localEulerAngles = Vector3.zero; Transform[] trans = obj.GetComponentsInChildren <Transform>(); for (int i = 0; i < trans.Length; i++) { trans[i].gameObject.layer = LayerMask.NameToLayer("UI"); } SkinnedMeshRenderer[] mes = obj.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int i = 0; i < mes.Length; i++) { mes[i].shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; mes[i].receiveShadows = false; } tex = new RenderTexture(512, 512, 100); tex.autoGenerateMips = false; tex.anisoLevel = 1; // tex.antiAliasing = 2 ca.targetTexture = tex; return(obj); }
private void LoadQueue() { if (currentNum >= count) { RunCallBack(); Destroy(); return; } PreloadResourcesDataGenerate da = queueRes[currentNum]; currentNum++; //Debug.Log("da.m_key " + da.m_key); try { Type resType = ReflectionUtils.GetTypeByTypeFullName(da.m_ResType); ResourceManager.LoadAsync(da.m_key, resType, (LoadState loadState, object loadRes) => { if (loadState.isDone) { if (loadRes != null && loadRes is GameObject) { if (da.m_instantiateNum > 0) { GameObject prefab = (GameObject)loadRes; for (int i = 0; i < da.m_instantiateNum; i++) { GameObject obj = GameObjectManager.CreateGameObject(prefab); GameObjectManager.DestroyGameObjectByPool(obj, !da.m_createInstanceActive); } } } else { if (loadRes == null) { Debug.LogError("Error: 预加载失败 key:" + da.m_key); } } RunCallBack(); LoadQueue(); } }); } catch (Exception e) { Debug.LogError(e); LoadQueue(); } }
static public Dictionary <string, List <UIWindowBase> > s_hideUIs = new Dictionary <string, List <UIWindowBase> >(); //隐藏的UI #region 初始化 public static void Init() { GameObject l_instance = GameObject.Find("UIManager"); if (l_instance == null) { l_instance = GameObjectManager.CreateGameObject("UIManager"); } s_UIManagerGo = l_instance; s_UILayerManager = l_instance.GetComponent <UILayerManager>(); s_UIAnimManager = l_instance.GetComponent <UIAnimManager>(); s_UIcamera = l_instance.GetComponentInChildren <Camera>(); DontDestroyOnLoad(l_instance); }
public override void OnEntityOptimizeCreate(EntityBase entity) { if (GetAllExistComp(new string[] { "AssetComponent", "TransfromComponent" }, entity)) { Debug.Log("接收到创建 "); AddComp(entity); AssetComponent ac = entity.GetComp <AssetComponent>(); TransfromComponent tc = entity.GetComp <TransfromComponent>(); PerfabComponent comp = entity.GetComp <PerfabComponent>(); comp.perfab = GameObjectManager.CreateGameObject(ac.m_assetName); comp.hardPoint = comp.perfab.GetComponent <HardPointComponent>(); if (tc.parentID == 0) { comp.perfab.transform.position = tc.pos.ToVector(); } else { EntityBase parent = m_world.GetEntity(tc.parentID); //if (parent.GetExistComp<PerfabComponent>()) //{ // PerfabComponent pc = parent.GetComp<PerfabComponent>(); // comp.perfab.transform.SetParent(pc.perfab.transform); //} comp.perfab.transform.localPosition = tc.pos.ToVector(); } //创建动画组件 if (comp.perfab.GetComponent <Animator>() != null) { AnimComponent anc = entity.AddComp <AnimComponent>(); anc.anim = comp.perfab.GetComponent <Animator>(); anc.perfab = comp.perfab; anc.waistNode = comp.hardPoint.waistNode; } } }
public static UIWindowBase CreateUIWindow(string UIName) { GameObject UItmp = GameObjectManager.CreateGameObject(UIName, s_UIManagerGo); UIWindowBase UIbase = UItmp.GetComponent <UIWindowBase>(); UISystemEvent.Dispatch(UIbase, UIEvent.OnInit); //派发OnInit事件 try{ UIbase.Init(GetUIID(UIName)); } catch (Exception e) { Debug.LogError("OnInit Exception: " + e.ToString()); } AddHideUI(UIbase); s_UILayerManager.SetLayer(UIbase); //设置层级 return(UIbase); }
public static UIModelShowData CreateModelData(string prefabName, string layerName = null, bool?orthographic = null, float?orthographicSize = null, Color?backgroundColor = null, Vector3?localPosition = null, Vector3?eulerAngles = null, Vector3?localScale = null, Vector3?texSize = null, float?nearClippingPlane = null, float?farClippingPlane = null) { //默认值设置 layerName = layerName ?? s_defaultLayer; Vector3 localPositionTmp = localPosition ?? s_defaultLocationPosition; Vector3 eulerAnglesTmp = eulerAngles ?? s_defaultEulerAngles; Vector3 texSizeTmp = texSize ?? s_defaultTexSize; Vector3 localScaleTmp = localScale ?? s_defaultLocalScale; Color backgroundColorTmp = backgroundColor ?? s_defaultBackgroundColor; float orthographicSizeTmp = orthographicSize ?? c_defaultOrthographicSize; bool orthographicTmp = orthographic ?? c_defaultOrthographic; float fieldOfView = orthographicSize ?? c_defaultFOV; float nearClippingPlaneTmp = nearClippingPlane ?? s_clippingPlanes.x; float farClippingPlaneTmp = farClippingPlane ?? s_clippingPlanes.y; //构造Camera UIModelShowData data = new UIModelShowData(); GameObject uiModelShow = new GameObject("UIShowModelCamera"); data.top = uiModelShow; GameObject camera = new GameObject("Camera"); camera.transform.SetParent(uiModelShow.transform); camera.transform.localPosition = Vector3.zero; Camera ca = camera.AddComponent <Camera>(); data.camera = ca; ca.clearFlags = CameraClearFlags.SolidColor; ca.backgroundColor = backgroundColorTmp; ca.orthographic = orthographicTmp; ca.orthographicSize = orthographicSizeTmp; ca.fieldOfView = fieldOfView; ca.depth = 100; ca.nearClipPlane = nearClippingPlaneTmp; ca.farClipPlane = farClippingPlaneTmp; ca.cullingMask = 1 << LayerMask.NameToLayer(layerName); GameObject root = new GameObject("Root"); data.root = root; root.transform.SetParent(camera.transform); root.transform.localPosition = localPositionTmp; root.transform.eulerAngles = eulerAnglesTmp; root.transform.localScale = localScaleTmp; //创建模型 GameObject obj = GameObjectManager.CreateGameObject(prefabName); data.model = obj; obj.transform.SetParent(root.transform); obj.transform.localPosition = new Vector3(0, 0, 0); obj.transform.localEulerAngles = Vector3.zero; obj.transform.localScale = Vector3.one; obj.SetLayer(LayerMask.NameToLayer(layerName)); SkinnedMeshRenderer[] mes = obj.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int i = 0; i < mes.Length; i++) { mes[i].shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; mes[i].receiveShadows = false; } //设置randerTexture RenderTexture tex = new RenderTexture((int)texSizeTmp.x, (int)texSizeTmp.y, (int)texSizeTmp.z); data.renderTexture = tex; tex.autoGenerateMips = false; tex.anisoLevel = 1; ca.targetTexture = tex; modelShowList.Add(data); ResetModelShowPosition(); return(data); }