/// <summary> /// 返回主厂区 /// </summary> public void BackToMainFactory() { if (LocationManager.Instance.IsFocus) { LocationManager.Instance.RecoverBeforeFocusAlign(() => { Debug.LogError("BackToMainFactory"); FactoryDepManager Manager = FactoryDepManager.Instance; if (Manager) { AddItems(FactoryDepManager.Instance); RoomFactory.Instance.FocusNode(Manager); } }, false); } else { FactoryDepManager Manager = FactoryDepManager.Instance; if (Manager) { AddItems(FactoryDepManager.Instance); RoomFactory.Instance.FocusNode(Manager); } } }
/// <summary> /// 获取parentID /// </summary> /// <returns></returns> private int GetPID(GameObject dev) { FactoryDepManager dep = FactoryDepManager.Instance; DepNode currentDep = FactoryDepManager.currentDep; int devPid; if (currentDep == null) { return(dep.NodeID); } if (currentDep as FloorController) { FloorController floor = currentDep as FloorController; Transform lastParent = dev.transform.parent; dev.transform.parent = floor.RoomDevContainer.transform; devPid = floor.GetDevBoundId(dev.transform.localPosition); dev.transform.parent = lastParent; } else if (currentDep as DepController || currentDep as BuildingController) { //区域和大楼,默认算厂区设备 return(dep.NodeID); } else { devPid = currentDep.NodeID; } return(devPid); }
/// <summary> /// 隐藏厂区建筑物 /// </summary> private void HideFacotry() { FactoryDepManager manager = FactoryDepManager.Instance; if (manager) { manager.HideFacotry(); } }
/// <summary> /// 显示厂区建筑 /// </summary> private void ShowFactory() { FactoryDepManager manager = FactoryDepManager.Instance; if (manager) { manager.ShowFactory(); } }
/// <summary> /// 区域切换响应事件 /// </summary> private void SwitchToFactory() { FactoryDepManager manager = FactoryDepManager.Instance; if (manager) { manager.OpenDep(); } }
/// <summary> /// 返回主厂区 /// </summary> public void BackToMainFactoryCall(Action callAction) { FactoryDepManager Manager = FactoryDepManager.Instance; if (Manager) { AddItems(FactoryDepManager.Instance); RoomFactory.Instance.FocusNode(Manager, callAction); } }
/// <summary> /// 设置设备的控制脚本 /// </summary> /// <param name="Info"></param> private DevNode SetDevController(DevInfo Info, GameObject copyModel) { FactoryDepManager depManager = FactoryDepManager.Instance; if (depManager) { copyModel.AddCollider(); if (Info.ParentId == depManager.NodeID) { copyModel.transform.parent = depManager.FactoryDevContainer.transform; return(DevControllerAdd(Info, copyModel, depManager)); } else { FloorController floor = FactoryDepManager.currentDep as FloorController; if (floor && Info.ParentId == floor.NodeID) { if (floor.RoomDevContainer != null) { return(InitRoomDevParent(copyModel, floor, floor.RoomDevContainer, Info)); } } else { if (floor != null) { DepNode room = floor.ChildNodes.Find(item => item.NodeID == Info.ParentId); if (room != null && room as RoomController) { RoomController controller = room as RoomController; return(InitRoomDevParent(copyModel, controller, controller.RoomDevContainer, Info)); } else { if (floor.RoomDevContainer != null) { return(InitRoomDevParent(copyModel, floor, floor.RoomDevContainer, Info)); } } } else { RoomController roomController = FactoryDepManager.currentDep as RoomController; if (roomController) { return(InitRoomDevParent(copyModel, roomController, roomController.RoomDevContainer, Info)); } } //Todo:保存到机柜 //Debug.Log("Check Dev PID:"+Info.ParentId); } } } return(null); }
// Use this for initialization void Awake() { Instance = this; depHideList = new List <DepNode>(); //Debug.LogError("FactoryDepManager_Awake"); depType = DepType.Factory; DepController[] DepControllers = GameObject.FindObjectsOfType <DepController>(); foreach (DepController dep in DepControllers) { if (!ChildNodes.Contains(dep)) { ChildNodes.Add(dep); } } //colliders = GetComponentsInChildren<Collider>().ToList(); }
/// <summary> /// 获取区域统计信息 /// </summary> private void TryGetAreaInfo() { FactoryDepManager dep = FactoryDepManager.Instance; if (dep == null) { Debug.LogError("FVIntroduce.TryGetAreaInfo dep == null"); return; } if (isRefresh) { Debug.Log("FVIntroduce.TryGetAreaInfo isRefresh:" + isRefresh); return; } isRefresh = true; CommunicationObject.Instance.GetAreaStatistics(dep.NodeID, AfterGetAreaInfo); }
/// <summary> /// 进入电厂 /// </summary> private void EnterFactory() { try { Log.Info("FullViewController.enter facotry start..."); SystemModeTweenManage.Instance.SetStartTween(); Log.Info("FullViewController.tween sequence start..."); SystemModeTweenManage.Instance.TweenSequence.OnComplete(() => { ParkInformationManage.Instance.ShowParkInfoUI(true); Log.Info("FullViewController.tween sequence end..."); SystemModeTweenManage.Instance.IsStartTween = false; SystemModeTweenManage.Instance.ModdleTween(); }).Restart(); if (AlarmPushManage.Instance) { AlarmPushManage.Instance.ShowIsShow(); } FactoryDepManager dep = FactoryDepManager.Instance; if (dep) { Log.Info("FullViewController.start creat factory dev..."); dep.CreateFactoryDev(); Log.Info("FullViewController.creat factory dev complete."); } IsDoingAnimation = false; isFullView = false; Log.Info("FullViewController.enter factory event start..."); SceneEvents.OnFullViewStateChange(isFullView); //MonitorRangeManager.Instance.ShowRanges(SceneEvents.DepNode); IsClickUGUIorNGUI.Instance.Recover();//解决鼠标右键旋转场景时,会跳一下的的问题(是IsClickUGUIorNGUI中鼠标点击检测问题) }catch (Exception e) { Log.Error("Error:FullViewController enter factory:" + e.ToString()); } }
// Update is called once per frame void OnGUI() { sortComponent.OnGUI(); EditorGUILayout.BeginHorizontal(); loadDistanceBiasText = GUILayout.TextField(loadDistanceBiasText, GUILayout.Width(50)); unloadDistanceBiasText = GUILayout.TextField(unloadDistanceBiasText, GUILayout.Width(50)); loadDistanceBias = float.Parse(loadDistanceBiasText); unloadDistanceBias = float.Parse(unloadDistanceBiasText); EditorGUILayout.EndHorizontal(); FactoryDepManager root = GameObject.FindObjectOfType <FactoryDepManager>(); if (root) { var allCount = GetVertexs(root.gameObject); GUILayout.Label("AllCount:" + allCount, EditorStyles.boldLabel); } GUILayout.Label("BuildingList:", EditorStyles.boldLabel); GUI_InitTableComponent(); var heightOffset = 180; scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - heightOffset));//开始滚动条 //var buildings = Resources.FindObjectsOfTypeAll<BuildingController>().ToList(); var buildings = new List <BuildingAssetInfo>(); var list1 = GameObject.FindObjectsOfType <BuildingAssetInfo>().ToList(); list1.Sort(sortComponent.SortMethod); for (int i = 0; i < list1.Count; i++) { var building = list1[i]; var meshRenderer = building.gameObject.GetComponentInChildren <MeshRenderer>(); if (meshRenderer == null) { continue; } buildings.Add(building); } for (int i = 0; i < buildings.Count; i++) { var building = buildings[i]; var obj = building.gameObject; //GUILayout.Toggle(meshRenderer != null, "MeshRenderer", GUILayout.Width(100)); var objName = obj.name; var parent = obj.transform.parent; var info = GetSceneAssetInfo(building); EditorGUILayout.BeginHorizontal(); GUILayout.Label(string.Format("{0:00}", i + 1), tableComponent.GetGUIWidth("ID")); info.SceneName = GUILayout.TextField(info.SceneName, tableComponent.GetGUIWidth("Scene")); var sceneName = info.SceneName; var vertexCount = GetVertexs(obj); GUILayout.Label(vertexCount + "", tableComponent.GetGUIWidth("Count")); if (parent != null) { if (GUILayout.Button(parent.name, tableComponent.GetGUIWidth("Parent"))) { SelectObject(parent.gameObject); } } else { if (GUILayout.Button("NULL", tableComponent.GetGUIWidth("Parent"))) { } } if (GUILayout.Button(obj.name, tableComponent.GetGUIWidth("Name"))) { SelectObject(obj); } //GUILayout.Label(building.NodeName, EditorStyles.label, tableComponent.GetGUIWidth("Node")); if (GUILayout.Button("Create")) { var scenePath = GetScenePath(sceneName); var cube = ReplaceBuildingCube(obj, info); //obj.SetActive(false); SelectObject(cube); var scene = EditorHelper.CreateScene(obj, scenePath); AssetDatabase.Refresh();//刷新编辑器 EditorHelper.SetAssetBundleName(scenePath, info.AssetName); EditorSceneManager.CloseScene(scene, true); return; } GameObject assetModel = null; if (!selectedObjects.ContainsKey(sceneName)) { assetModel = FindModelAsset(sceneName); selectedObjects.Add(sceneName, assetModel); } else { assetModel = selectedObjects[sceneName]; } var meshPath = EditorHelper.GetMeshPath(obj); var modelPath = AssetDatabase.GetAssetPath(assetModel); GUILayout.Toggle(meshPath == modelPath, "独立文件", GUILayout.Width(60)); var selectedObj = (GameObject)EditorGUILayout.ObjectField(assetModel, typeof(GameObject), false, GUILayout.Width(110)); selectedObjects[sceneName] = selectedObj; GameObject simpleOjb = GetSimpleObject(obj); EditorGUILayout.ObjectField(simpleOjb, typeof(GameObject), false, GUILayout.Width(110)); if (GUILayout.Button("ReplaceObj")) { ReplaceBuildingObject(obj, info, sceneName, selectedObj, ""); } if (GUILayout.Button("ReplaceCube")) { var cube = ReplaceBuildingCube(obj, info); obj.SetActive(false); SelectObject(cube); } if (simpleOjb == null) { if (GUILayout.Button("", GUILayout.Width(100))) { } } else { var simpleVertexCount = GetVertexs(simpleOjb); if (GUILayout.Button(simpleVertexCount + "", GUILayout.Width(100))) { //assetModel = simpleOjb; ReplaceBuildingObject(obj, info, sceneName, simpleOjb, "_Simple"); } } if (GUILayout.Button("Path")) { var path1 = AssetDatabase.GetAssetPath(obj); Debug.Log("path1:" + path1); var path2 = EditorHelper.GetMeshPath(obj); Debug.Log("path2:" + path2); //var path3 = AssetDatabase.GetAssetPath(assetModel); //Debug.Log("path3:" + path3); Debug.Log("GetDependencies"); var dependencies = AssetDatabase.GetDependencies(path2); foreach (var item in dependencies) { Debug.Log("" + item); //var assetPath = AssetDatabase.GUIDToAssetPath(guid); } //Object parentObject = EditorUtility.GetPrefabParent(obj); //string path4 = AssetDatabase.GetAssetPath(parentObject); //Debug.Log("prefab path4:" + path4); ////Path. ////Projector //GameObject simpleOjb2 = GetSimpleObject(obj); } if (GUILayout.Button("Resource")) { //var meshPath = GetMeshPath(obj); Log.Info("meshPath:" + meshPath); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("CreateAll")) { Debug.Log("CreateAll"); for (int i = 0; i < buildings.Count; i++) { var building = buildings[i]; var obj = building.gameObject; var info = GetSceneAssetInfo(building); var scenePath = GetScenePath(info.SceneName); var cube = ReplaceBuildingCube(obj, info); var scene = EditorHelper.CreateScene(obj, scenePath); AssetDatabase.Refresh();//刷新编辑器 EditorHelper.SetAssetBundleName(scenePath, info.AssetName); EditorSceneManager.CloseScene(scene, true); } SaveInfo(); } if (GUILayout.Button("ReplaceBoxAll")) { ReplaceBoxAll(buildings); } if (GUILayout.Button("ReplaceSimpleAll")) { //ReplaceBoxAll(buildings); ReplaceSimpleAll(buildings); //SaveInfo(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("ClearScene")) { EditorHelper.ClearOtherScenes(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("LoadInfo")) { LoadInfo(); } if (GUILayout.Button("SaveInfo")) { SaveInfo(); } if (GUILayout.Button("Reset")) { infos = new Dictionary <string, SceneAssetInfo>(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("SetChunkManager")) { SetChunkManager(buildings); } if (GUILayout.Button("SetFromHttp")) { ChunkManager cm = GameObject.FindObjectOfType <ChunkManager>(); if (cm) { foreach (var chunk in cm.chunks) { foreach (var bundle in chunk.bundleList) { bundle.fromFile = false; bundle.checkVersion = true; } } } } if (GUILayout.Button("SetFromFile")) { ChunkManager cm = GameObject.FindObjectOfType <ChunkManager>(); if (cm) { foreach (var chunk in cm.chunks) { foreach (var bundle in chunk.bundleList) { bundle.fromFile = true; bundle.checkVersion = false; } } } } EditorGUILayout.EndHorizontal(); }
/// <summary> /// 显示当前建筑 /// </summary> public void ShowFactory() { FactoryDepManager depManager = FactoryDepManager.Instance; depManager.ShowFactory(); }
///// <summary> ///// 载入机房 ///// </summary> ///// <param name="depNode"></param> ///// <param name="isFocusRoom"></param> ///// <param name="onComplete"></param> //public IEnumerator LoadRoomStartCoroutine(DepNode depNode, bool isFocusRoom = false, Action<FloorController> onComplete = null) //{ // if (depNode == null) // { // Debug.Log("RoomID is null..."); // yield break; // } // //SceneBackButton.Instance.Show(BackToBuilding); // HideFacotory(); // RoomCreate(depNode, isFocusRoom, onComplete); //} /// <summary> /// 隐藏当前建筑 /// </summary> private void HideFacotory() { FactoryDepManager depManager = FactoryDepManager.Instance; depManager.HideFacotry(); }