private static int NewChild(ILuaState lua) { GameObject parent, child; ApplyParentAndChild(lua, out parent, out child); if (child != null) { string goName = lua.OptString(3, child.name); GameObject go = GoTools.AddChild(parent, child); int sibling = lua.OptInteger(4, -1); if (parent) { if (sibling < 0) { sibling = parent.transform.childCount + sibling; } go.transform.SetSiblingIndex(sibling); } if (go != null) { go.name = goName; lua.PushLightUserData(go); } else { lua.PushNil(); } } else { lua.PushNil(); } return(1); }
public static void InitEntry() { #if UNITY_EDITOR var obj = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/" + ZFrame.Asset.AssetBundleLoader.DIR_ASSETS + "/AssetsMgr.prefab", typeof(GameObject)); GoTools.AddChild(null, obj as GameObject); LogMgr.D("Game Launched from Level: {0}", SceneManager.GetActiveScene().name); #endif }
private static void chkWeaponPrefab(GameObject go) { var root = go.transform; var modelTrans = root.Find(MODEL_NAME); if (modelTrans == null) { string path = string.Format("Assets/Artwork/Model/Weapon/{0}.FBX", go.name); GameObject model = AssetDatabase.LoadAssetAtPath <GameObject>(path); if (model) { modelTrans = GoTools.AddChild(go, model).transform; modelTrans.name = MODEL_NAME; } else { EditorUtility.DisplayDialog("提示", string.Format("未找到模型:\n{0}", path), "确定"); return; } } modelTrans.localRotation = Quaternion.Euler(0, -90, -90); var rdr = modelTrans.GetComponentInChildren <SkinnedMeshRenderer>(); if (rdr) { var mesh = rdr.gameObject.AddComponent <MeshFilter>(); mesh.sharedMesh = rdr.sharedMesh; var meshRdr = rdr.gameObject.AddComponent <MeshRenderer>(); meshRdr.sharedMaterials = rdr.sharedMaterials; meshRdr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; meshRdr.receiveShadows = false; meshRdr.useLightProbes = false; meshRdr.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; SkinnedMeshRenderer.DestroyImmediate(rdr); } var muzzle = root.Find(MUZZLE_NAME); if (muzzle == null) { var goM = GoTools.AddChild(go, (GameObject)null); goM.name = MUZZLE_NAME; muzzle = goM.transform; muzzle.SetParent(root); } muzzle.localRotation = Quaternion.Euler(0, -90, 0); go.SetLayerRecursively(LayerMask.NameToLayer("Role")); }
protected override void Awaking() { Application.logMessageReceived += logMessageReceived; logBuilder = new System.Text.StringBuilder(1024 * Kcapacity); counting = 0; hasUpdate = false; entText = grpText.GetChild(0).gameObject; GameObject newText = GoTools.AddChild(grpText.gameObject, entText); newText.name = "entText1"; newText.SetActive(true); m_LogContent = newText.GetComponent <Text>(); listText.Add(newText); }
public TcpClientHandler GetTcpHandler(string tcpName) { TcpClientHandler tcpHandler = null; var trans = cachedTransform.Find(tcpName); if (!trans) { var go = GoTools.AddChild(gameObject); go.name = tcpName; tcpHandler = go.AddComponent <TcpClientHandler>(); } else { tcpHandler = trans.GetComponent <TcpClientHandler>(); } return(tcpHandler); }
public HttpHandler GetHttpHandler(string httpName) { HttpHandler httpHandler = null; var trans = cachedTransform.Find(httpName); if (!trans) { var go = GoTools.AddChild(gameObject); go.name = httpName; httpHandler = go.AddComponent <HttpHandler>(); httpHandler.onHttpResp = OnHttpResponse; httpHandler.onHttpDL = OnHttpDownload; } else { httpHandler = trans.GetComponent <HttpHandler>(); } return(httpHandler); }
private void logMessageReceived(string condition, string stackTrace, LogType logType) { counting += 1; string toAppend = null; switch (logType) { case LogType.Log: case LogType.Warning: toAppend = string.Format(ColorFmt[(int)logType], counting, condition); break; case LogType.Assert: case LogType.Error: case LogType.Exception: toAppend = string.Format(ColorFmt[(int)logType], counting, condition, stackTrace); break; default: break; } var logLength = logBuilder.Length + toAppend.Length; if (logLength >= logBuilder.Capacity) { m_LogContent.text = m_LogContent.text.Remove(m_LogContent.text.Length - 1); logBuilder = new System.Text.StringBuilder(Kcapacity * 1024); GameObject newText = GoTools.AddChild(grpText.gameObject, entText); newText.name = "entText" + (listText.Count + 1); newText.SetActive(true); m_LogContent = newText.GetComponent <Text>(); listText.Add(newText); } logBuilder.AppendLine(toAppend); hasUpdate = true; }
// Use this for initialization private IEnumerator Start() { AssetsMgr.A.Loader.StopLoading(); AssetsMgr.A.Loader.UnloadAll(); sldLoading.gameObject.SetActive(false); yield return(null); if (!string.IsNullOrEmpty(loadingFx)) { AssetsMgr.A.LoadAsync(typeof(GameObject), loadingFx, true, (uObj, o) => { var prefab = uObj as GameObject; if (prefab.GetComponent <RectTransform>()) { GoTools.AddChild(transform.parent.gameObject, prefab); } else { GoTools.AddChild(null, prefab); } }); } else { sldLoading.gameObject.SetActive(true); sldLoading.value = 0f; } strTrace = new System.Text.StringBuilder(); beginTime = Time.realtimeSinceStartup; lastTime = beginTime; // 执行预加载 nAssetBundleLoaded = 0; nAssetBundleToLoad = AssetsMgr.A.Loader.ExecutePreload(OnAssetBundlesLoading, OnAssetBundlesLoaded); float progress = 0; while (nAssetBundleLoaded < nAssetBundleToLoad) { float add = assetsRate - progress; progress += Mathf.Min(add, barStep); sldLoading.value = progress * assetsProg; yield return(null); } assetsProg = sldLoading.value; var asynOpt = AssetsMgr.A.Loader.LoadLevelAsync(levelToLoad); progress = 0; while (!asynOpt.isDone) { float add = asynOpt.progress - progress; progress += Mathf.Min(add, barStep); sldLoading.value = progress * (1 - assetsProg) + assetsProg; yield return(null); } while (sldLoading.value < 1) { sldLoading.value += barStep; yield return(null); } yield return(new WaitForSeconds(2)); finishLoading(); //StartCoroutine("FinishLoading"); ObjectPoolManager.DestroyPooled(gameObject); }