// 創建場景 private void CreateScene() { SceneImageRes imgRes = this.ImageRes; if (imgRes == null || m_Config == null || !m_Config.IsVaild) { return; } var bgCfg = m_Config.BgCfg; if (bgCfg == null) { return; } InitCamera(); for (int i = 0; i < bgCfg.BgCount; ++i) { IBg bg = bgCfg.GetBg(i); if (bg == null) { continue; } CreateSceneLayer(bg); } var cam = AppConfig.GetInstance().m_Camera; if (cam != null) { var pt = cam.ScreenToWorldPoint(Vector3.zero); pt.y = 0; pt.z = 0; this.transform.position = pt; } }
private void CreateSceneLayer(IBg bg) { if (bg == null || bg.bgType == BgType.none) { return; } // if (bg.name != "10" && bg.name != "20") // return; GameObject obj = new GameObject(bg.name, typeof(SceneLayerDisplay)); var trans = obj.transform; trans.SetParent(this.transform, false); //var cam = AppConfig.GetInstance ().m_Camera; Vector3 pt = new Vector3(bg.start_x, -bg.start_y, 0) / PlayerDisplay._cScenePerUnit; //pt = cam.ScreenToWorldPoint (pt); pt = pt / 100.0f; Vector3 p = trans.localPosition; p.x = pt.x; p.y = pt.y; float offz = ((float)bg.GenId) / 100.0f; p.z = bg.layerno > 0 ? -8.9f + offz: 9.9f - offz; trans.localPosition = p; trans.localScale = Vector3.one; trans.localRotation = Quaternion.identity; var dislpay = obj.GetComponent <SceneLayerDisplay>(); dislpay.layerno = bg.layerno; if (bg.bgType == BgType.normal) { dislpay.InitStatic(bg as BgStaticInfo); dislpay.AdjustPos(); } else if (bg.bgType == BgType.anim) { dislpay.InitAnimated(bg as BgAniInfo); dislpay.AdjustPos(); } }
private void CreateSceneLayer(IBg bg) { if (bg == null || bg.bgType == BgType.none) { return; } GameObject obj = new GameObject(bg.name, typeof(SceneLayerDisplay)); var trans = obj.transform; trans.SetParent(this.transform, false); trans.localPosition = Vector3.zero; trans.localScale = Vector3.one; trans.localRotation = Quaternion.identity; var dislpay = obj.GetComponent <SceneLayerDisplay>(); dislpay.layerno = bg.layerno; if (bg.bgType == BgType.normal) { dislpay.InitStatic(bg as BgStaticInfo); } }
// 創建場景 private void CreateScene() { SceneImageRes imgRes = this.ImageRes; if (imgRes == null || m_Config == null || !m_Config.IsVaild) { return; } var bgCfg = m_Config.BgCfg; if (bgCfg == null) { return; } for (int i = 0; i < bgCfg.BgCount; ++i) { IBg bg = bgCfg.GetBg(i); if (bg == null) { continue; } CreateSceneLayer(bg); } }