private ItemInSceneInfo FindItemInSceneInfo(ItemInScene itemInScene, string scenePath) { foreach (var info in itemInScene.itemInfo) { if (info.path == scenePath) { return(info); } } return(null); }
public void BeginLook(Item _item, ItemInScene itemInScene) { thingInspecting = itemInScene; foreach (Transform child in transform) Destroy(child.gameObject); item = _item; GetComponentInParent<Camera>().enabled = true; GameObject.FindGameObjectWithTag("Player").GetComponent<CharacterCont>().SetEnabled(false); transform.rotation = new Quaternion(); transform.Rotate(Vector3.up, 45); Instantiate(item.display, transform.position, new Quaternion(), transform); justEntered = true; inspectText.text = item.description.text; looking = true; }
private void ListAllSceneMeshes() { meshListScrollPos = EditorGUILayout.BeginScrollView(meshListScrollPos); foreach (var sceneMesh in SceneMeshes) { if (sceneMesh.mesh != null) { GUILayout.BeginHorizontal(); if (GUILayout.Button(sceneMesh.mesh.name, GUILayout.Width(150))) { SelectObject(sceneMesh.mesh, ctrlPressed); } string sizeLabel = "" + sceneMesh.mesh.vertexCount + " vert"; GUILayout.Label(sizeLabel, GUILayout.Width(100)); if (GUILayout.Button(sceneMesh.itemInfo.Count + " Sce", GUILayout.Width(50))) { if (currentInfo != null) { currentInfo = null; } else { currentInfo = sceneMesh; } } GUILayout.BeginVertical(); foreach (var info in sceneMesh.itemInfo) { GUILayout.BeginHorizontal(); ItemInSceneInfo itemInSceneInfo = sceneMesh.itemInfo.Find(delegate(ItemInSceneInfo obj) { return obj.path == info.path; }); if (GUILayout.Button(itemInSceneInfo.usedCount + " GO", GUILayout.Width(50))) { EditorApplication.OpenScene(info.path); CheckCurrentSceneResources(); foreach (var tDetails in ActiveMeshDetails) { if (tDetails.mesh == sceneMesh.mesh) { List<Object> FoundObjects = new List<Object>(); foreach (MeshFilter meshFilter in tDetails.FoundInMeshFilters) FoundObjects.Add(meshFilter.gameObject); SelectObjects(FoundObjects, ctrlPressed); } } } if (GUILayout.Button(itemInSceneInfo.usedCount1 + " GO", GUILayout.Width(50))) { EditorApplication.OpenScene(info.path); CheckCurrentSceneResources(); foreach (var tDetails in ActiveMeshDetails) { if (tDetails.mesh == sceneMesh.mesh) { List<Object> FoundObjects = new List<Object>(); foreach (SkinnedMeshRenderer skinnedMeshRenderer in tDetails.FoundInSkinnedMeshRenderer) FoundObjects.Add(skinnedMeshRenderer.gameObject); SelectObjects(FoundObjects, ctrlPressed); } } } GUILayout.Label(info.path); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); }
private ItemInSceneInfo FindItemInSceneInfo(ItemInScene itemInScene, string scenePath) { foreach (var info in itemInScene.itemInfo) { if (info.path == scenePath) { return info; } } return null; }
void CheckAllSceneResources() { SceneTextures.Clear(); SceneMaterials.Clear(); SceneMeshes.Clear(); foreach (UnityEditor.EditorBuildSettingsScene scene in UnityEditor.EditorBuildSettings.scenes) { if (scene.enabled) { EditorApplication.OpenScene(scene.path); CheckCurrentSceneResources(); foreach (var tex in ActiveTextures) { string texPath = AssetDatabase.GetAssetPath(tex.texture); if (!texPath.Contains("Brush") && !texPath.Contains("MapData_")) { var tTextureInScene = FindTextureInScene(tex.texture); if (tTextureInScene == null) { tTextureInScene = new ItemInScene(); SceneTextures.Add(tTextureInScene); tTextureInScene.isCubeMap = tex.isCubeMap; tTextureInScene.format = tex.format; tTextureInScene.memSizeKB = tex.memSizeKB; tTextureInScene.mipMapCount = tex.mipMapCount; tTextureInScene.texture = tex.texture; } var itemInfo = FindItemInSceneInfo(tTextureInScene, scene.path); if (itemInfo == null) { itemInfo = new ItemInSceneInfo(); itemInfo.path = scene.path; tTextureInScene.itemInfo.Add(itemInfo); } itemInfo.usedCount += tex.FoundInRenderers.Count; foreach (var mat in tex.FoundInMaterials) { if (!tTextureInScene.FoundInMaterials.Contains(mat)) { tTextureInScene.FoundInMaterials.Add(mat); } } } } foreach (var ma in ActiveMaterials) { var tMaterialInScene = FindMaterialInScene(ma.material); if (tMaterialInScene == null) { tMaterialInScene = new ItemInScene(); SceneMaterials.Add(tMaterialInScene); tMaterialInScene.material = ma.material; } var itemInfo = FindItemInSceneInfo(tMaterialInScene, scene.path); if (itemInfo == null) { itemInfo = new ItemInSceneInfo(); itemInfo.path = scene.path; tMaterialInScene.itemInfo.Add(itemInfo); } itemInfo.usedCount += ma.FoundInRenderers.Count; } foreach (var me in ActiveMeshDetails) { var tMeshInScene = FindMeshInScene(me.mesh); if (tMeshInScene == null) { tMeshInScene = new ItemInScene(); SceneMeshes.Add(tMeshInScene); tMeshInScene.mesh = me.mesh; } var itemInfo = FindItemInSceneInfo(tMeshInScene, scene.path); if (itemInfo == null) { itemInfo = new ItemInSceneInfo(); itemInfo.path = scene.path; tMeshInScene.itemInfo.Add(itemInfo); } itemInfo.usedCount += me.FoundInMeshFilters.Count; itemInfo.usedCount1 += me.FoundInSkinnedMeshRenderer.Count; } } } SceneMaterials.Sort(delegate(ItemInScene info1, ItemInScene info2) { return info2.itemInfo.Count - info1.itemInfo.Count; }); SceneMeshes.Sort(delegate(ItemInScene info1, ItemInScene info2) { return info2.itemInfo.Count - info1.itemInfo.Count; }); }
private void ListAllSceneMeshes() { meshListScrollPos = EditorGUILayout.BeginScrollView(meshListScrollPos); foreach (var sceneMesh in SceneMeshes) { if (sceneMesh.mesh != null) { GUILayout.BeginHorizontal(); if (GUILayout.Button(sceneMesh.mesh.name, GUILayout.Width(150))) { SelectObject(sceneMesh.mesh, ctrlPressed); } string sizeLabel = "" + sceneMesh.mesh.vertexCount + " vert"; GUILayout.Label(sizeLabel, GUILayout.Width(100)); if (GUILayout.Button(sceneMesh.itemInfo.Count + " Sce", GUILayout.Width(50))) { if (currentInfo != null) { currentInfo = null; } else { currentInfo = sceneMesh; } } GUILayout.BeginVertical(); foreach (var info in sceneMesh.itemInfo) { GUILayout.BeginHorizontal(); ItemInSceneInfo itemInSceneInfo = sceneMesh.itemInfo.Find(delegate(ItemInSceneInfo obj) { return(obj.path == info.path); }); if (GUILayout.Button(itemInSceneInfo.usedCount + " GO", GUILayout.Width(50))) { EditorApplication.OpenScene(info.path); CheckCurrentSceneResources(); foreach (var tDetails in ActiveMeshDetails) { if (tDetails.mesh == sceneMesh.mesh) { List <Object> FoundObjects = new List <Object>(); foreach (MeshFilter meshFilter in tDetails.FoundInMeshFilters) { FoundObjects.Add(meshFilter.gameObject); } SelectObjects(FoundObjects, ctrlPressed); } } } if (GUILayout.Button(itemInSceneInfo.usedCount1 + " GO", GUILayout.Width(50))) { EditorApplication.OpenScene(info.path); CheckCurrentSceneResources(); foreach (var tDetails in ActiveMeshDetails) { if (tDetails.mesh == sceneMesh.mesh) { List <Object> FoundObjects = new List <Object>(); foreach (SkinnedMeshRenderer skinnedMeshRenderer in tDetails.FoundInSkinnedMeshRenderer) { FoundObjects.Add(skinnedMeshRenderer.gameObject); } SelectObjects(FoundObjects, ctrlPressed); } } } GUILayout.Label(info.path); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); }
void CheckAllSceneResources() { SceneTextures.Clear(); SceneMaterials.Clear(); SceneMeshes.Clear(); foreach (UnityEditor.EditorBuildSettingsScene scene in UnityEditor.EditorBuildSettings.scenes) { if (scene.enabled) { EditorApplication.OpenScene(scene.path); CheckCurrentSceneResources(); foreach (var tex in ActiveTextures) { string texPath = AssetDatabase.GetAssetPath(tex.texture); if (!texPath.Contains("Brush") && !texPath.Contains("MapData_")) { var tTextureInScene = FindTextureInScene(tex.texture); if (tTextureInScene == null) { tTextureInScene = new ItemInScene(); SceneTextures.Add(tTextureInScene); tTextureInScene.isCubeMap = tex.isCubeMap; tTextureInScene.format = tex.format; tTextureInScene.memSizeKB = tex.memSizeKB; tTextureInScene.mipMapCount = tex.mipMapCount; tTextureInScene.texture = tex.texture; } var itemInfo = FindItemInSceneInfo(tTextureInScene, scene.path); if (itemInfo == null) { itemInfo = new ItemInSceneInfo(); itemInfo.path = scene.path; tTextureInScene.itemInfo.Add(itemInfo); } itemInfo.usedCount += tex.FoundInRenderers.Count; foreach (var mat in tex.FoundInMaterials) { if (!tTextureInScene.FoundInMaterials.Contains(mat)) { tTextureInScene.FoundInMaterials.Add(mat); } } } } foreach (var ma in ActiveMaterials) { var tMaterialInScene = FindMaterialInScene(ma.material); if (tMaterialInScene == null) { tMaterialInScene = new ItemInScene(); SceneMaterials.Add(tMaterialInScene); tMaterialInScene.material = ma.material; } var itemInfo = FindItemInSceneInfo(tMaterialInScene, scene.path); if (itemInfo == null) { itemInfo = new ItemInSceneInfo(); itemInfo.path = scene.path; tMaterialInScene.itemInfo.Add(itemInfo); } itemInfo.usedCount += ma.FoundInRenderers.Count; } foreach (var me in ActiveMeshDetails) { var tMeshInScene = FindMeshInScene(me.mesh); if (tMeshInScene == null) { tMeshInScene = new ItemInScene(); SceneMeshes.Add(tMeshInScene); tMeshInScene.mesh = me.mesh; } var itemInfo = FindItemInSceneInfo(tMeshInScene, scene.path); if (itemInfo == null) { itemInfo = new ItemInSceneInfo(); itemInfo.path = scene.path; tMeshInScene.itemInfo.Add(itemInfo); } itemInfo.usedCount += me.FoundInMeshFilters.Count; itemInfo.usedCount1 += me.FoundInSkinnedMeshRenderer.Count; } } } SceneMaterials.Sort(delegate(ItemInScene info1, ItemInScene info2) { return(info2.itemInfo.Count - info1.itemInfo.Count); }); SceneMeshes.Sort(delegate(ItemInScene info1, ItemInScene info2) { return(info2.itemInfo.Count - info1.itemInfo.Count); }); }