// ================================== PUBLIC FUNCS ================================== #region Public Funcs public void Save() { SetDefaultPath(); SceneJsonObj sceneJsonObj = new SceneJsonObj(); for (int i = 0; i < m_lSceneDesignInfo.Count; i++) { SceneDesignInfo sceneDesignInfo = m_lSceneDesignInfo[i]; SceneInfo sceneInfo = new SceneInfo(); sceneInfo.m_Type = sceneDesignInfo.m_Type; sceneInfo.m_PrefPath = UtilityClass.GetPathOfObj(sceneDesignInfo.m_Pref); sceneInfo.m_lElementLoc = new List <ObjLocation>(sceneDesignInfo.m_lElementLoc); sceneJsonObj.m_lSceneInfo.Add(sceneInfo); } Debug.Log("saving ___ total SCENE info = " + sceneJsonObj.m_lSceneInfo.Count); string json = JsonUtility.ToJson(sceneJsonObj); Debug.Log(json); if (json.Length > 0) { File.WriteAllText(FILE_DB_RAW_PATH, json); } }
// ================================== UNITY FUNCS ================================== #region Unity funcs private void Update() { Rect camRect = CameraController.GetCamRectInEditor(); for (int i = 0; i < transform.childCount; i++) { GameObject sceneObj = transform.GetChild(i).gameObject; if (!sceneObj.active) { continue; } for (int j = 0; j < m_lSceneDesignInfo.Count; j++) { SceneDesignInfo sceneInfo = m_lSceneDesignInfo[j]; if (sceneObj == sceneInfo.m_Pref) { if (sceneInfo.m_lElementLoc.Count != sceneObj.transform.childCount) { sceneInfo.m_lElementLoc.Clear(); } // update scene info for (int k = 0; k < sceneObj.transform.childCount; k++) { GameObject sceneElementObj = sceneObj.transform.GetChild(k).gameObject; ObjLocation objLocation = sceneInfo.m_lElementLoc.Find(x => x.m_ObjName == sceneElementObj.name); // update location rect of element if (objLocation != null) { // scale for all width & height if (objLocation.m_ScaleSameByY != 0) { SpriteRenderer srElement = sceneElementObj.GetComponent <SpriteRenderer>(); float elementScale = (camRect.height * objLocation.m_ScaleSameByY * 100.0f) / srElement.sprite.rect.height; sceneElementObj.transform.localScale = new Vector3(elementScale, elementScale, 1.0f); } objLocation.m_Rect = GetRectOfObjOnScene(camRect, sceneElementObj); } // add new rect of element else { objLocation = new ObjLocation(); objLocation.m_ObjName = sceneElementObj.name; objLocation.m_Rect = GetRectOfObjOnScene(camRect, sceneElementObj); sceneInfo.m_lElementLoc.Add(objLocation); } } break; } } } }