private void OnGUI() { /*if(debugTexture) { GUI.Button(new Rect(10,10,200,200),debugTexture); }*/ GUI.skin = ui; GUI.Box(new Rect(0,0,Screen.width,40),""); GUI.Box(new Rect(0,Screen.height-40,Screen.width,40),""); if(editorIsLoading) { GUI.Label(new Rect(20,10,500,34),"Loading Assets... <size=12>(Might be slower when loading first time)</size>"); GUI.Label(new Rect(20,Screen.height-30,500,34),"Click HELP for Camera Contorls and other Shortcuts"); return; } if(isItLoad&&!editorIsLoading) { if(!_uteLM.isMapLoaded) { GUI.Label(new Rect(20,10,200,34),"Loading Assets..."); return; } } if(saveMap.isSaving) { GUI.Label(new Rect(20,10,200,34),"Saving Assets..."); return; } if(erase) { GUI.Label(new Rect(150,75,500,30),"(Eraser: Hold left click: erase fast, right click: erase one/click)"); } if(isInTopView) { GUI.Label(new Rect(Screen.width/2-30,65,70,30),"[Top View]"); } if(isBuildingTC&&allTCTiles.Count<=0) { GUI.Label(new Rect(20,10,200,34),"[No TileConnections]"); } else if(allTiles.Count<=0) { GUI.Label(new Rect(20,10,200,34),"[No Tiles found]"); } if(isShowCameraOptions) { GUI.Box(cameraOptionsRect,""); if(GUI.Button(new Rect(Screen.width-500,Screen.height-69,100,28),"Reset")) { ResetCamera(); } if(GUI.Button(new Rect(Screen.width-390,Screen.height-69,100,28),"Top View")) { ShowTopView(); } if(GUI.Button(new Rect(Screen.width-280,Screen.height-69,90,28),"<- 90deg")) { StartCoroutine(TurnCamera90(9,-10)); } if(GUI.Button(new Rect(Screen.width-190,Screen.height-69,90,28),"90deg ->")) { StartCoroutine(TurnCamera90(9,10)); } } if(GUI.Button(new Rect(Screen.width-90,Screen.height-40,40,40),"+")) { if(is2D||isInTopView) { StartCoroutine(cameraMove.MoveUpDown(false,false)); } else { StartCoroutine(cameraMove.MoveUpDown(false,true)); } } if(GUI.Button(new Rect(Screen.width-50,Screen.height-40,40,40),"-")) { if(is2D||isInTopView) { StartCoroutine(cameraMove.MoveUpDown(true,false)); } else { StartCoroutine(cameraMove.MoveUpDown(true,true)); } } GUI.Label(new Rect(230,Screen.height-30,300,35),"["+newProjectName+"] Object Count: "+uteGLOBAL3dMapEditor.mapObjectCount); string tMode = "Tiles"; if(isBuildingTC) tMode = "Tile-Connections"; if(GUI.Button(new Rect(220,0,260,40),"Tile Mode: "+tMode)) { if(isBuildingTC) { isBuildingTC = false; } else { isBuildingTC = true; isContinuesBuild = true; isBuildingMass = false; } if(currentTile) { Destroy(currentTile); ShowLineHelpers(isShowLineHelpers = false); currentObjectID = "-1"; helpers_CANTBUILD.transform.position = new Vector3(-1000000.0f,0.0f,-1000000.0f); } } if(isBuildingTC) { if(allTCTiles.Count>0) { int selectedItemIndex = comboBoxForTileConnectionControl.GetSelectedItemIndex(); selectedItemIndex = comboBoxForTileConnectionControl.List(GUIComboBoxColliderTC, comboBoxList_TileConnections[selectedItemIndex].text+" ^", comboBoxList_TileConnections,listStyle); if(lastSelectedIndexTC!=selectedItemIndex) { lastSelectedIndexTC = selectedItemIndex; tcGoes = ((tcInfo) allTCTiles[selectedItemIndex]).tcObjs; tcPrevs = ((tcInfo) allTCTiles[selectedItemIndex]).tcObjsPrevs; tcNames = ((tcInfo) allTCTiles[selectedItemIndex]).tcObjsNames; tcGuids = ((tcInfo) allTCTiles[selectedItemIndex]).tcGuidNames; tcRots = ((tcInfo) allTCTiles[selectedItemIndex]).tcRotsNames; currentTcFamilyName = comboBoxList_TileConnections[selectedItemIndex].text; ShowLineHelpers(isShowLineHelpers = false); } if(!comboBoxForTileConnectionControl.isClickedComboButton) { GUIObjsColliderTC = new Rect(0,0,128,tcGoes.Count*125); checkGUIObjsColliderTC = new Rect(0,0,148,tcGoes.Count*125); scrollPositionTC = GUI.BeginScrollView(new Rect(0,40,145,Screen.height-80),scrollPositionTC,GUIObjsColliderTC); int startDrawPoint = (int) (scrollPositionTC.y/115); int endDrawPoint; if(tcGoes.Count-startDrawPoint>=7) { endDrawPoint = startDrawPoint; } else { endDrawPoint = startDrawPoint + (tcGoes.Count-startDrawPoint); } GUI.Box(GUIObjsColliderTC,""); for(int i=startDrawPoint;i<endDrawPoint;i++) { if(i>=0&&i<tcGoes.Count && (GameObject) tcGoes[i]) { if((Texture2D)tcPrevs[i]) { previewObjTextureTC = (Texture2D) tcPrevs[i]; } if(GUI.Button (new Rect(8,5+(i*122),115,115),previewObjTextureTC)) { if(currentTile) { Destroy(currentTile); } currentTCID = i; currentTile = (GameObject) Instantiate((GameObject)tcGoes[i],new Vector3(0.0f,0.0f,0.0f),((GameObject)tcGoes[i]).transform.rotation); uteTagObject tempTag = (uteTagObject) currentTile.AddComponent<uteTagObject>(); tempTag.objGUID = tcGuids[i].ToString(); tempTag.isStatic = isCurrentStatic; if(isBuildingTC) { tempTag.isTC = true; } currentTile.AddComponent<Rigidbody>(); currentTile.GetComponent<Rigidbody>().useGravity = false; currentTile.GetComponent<BoxCollider>().size -= new Vector3(0.01f,0.01f,0.01f); currentTile.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ; currentTile.GetComponent<Collider>().isTrigger = true; currentTile.AddComponent<uteDetectBuildCollision>(); currentTile.layer = 2; currentObjectID = tcNames[i].ToString(); isRotated = 0; isRotatedH = 0; erase = false; } GUI.Label(new Rect(14,7+(i*122),115,50),(string)tcNames[i]); if(!previewObjTextureTC) { GUI.Label(new Rect(18,50+(i*122),115,30),"NO PREVIEW"); } } } GUI.EndScrollView(); } } } else if(!isBuildingTC) { if(allTiles.Count!=0) { if(allTiles.Count>0) { int selectedItemIndex = comboBoxControl.GetSelectedItemIndex(); selectedItemIndex = comboBoxControl.List(GUIComboBoxCollider, comboBoxList[selectedItemIndex].text+" ^", comboBoxList, listStyle ); if(lastSelectedIndex!=selectedItemIndex) { uMBE.StepOne(); lastSelectedIndex = selectedItemIndex; catGoes = ((catInfo) allTiles[selectedItemIndex]).catObjs; catPrevs = ((catInfo) allTiles[selectedItemIndex]).catObjsPrevs; catNames = ((catInfo) allTiles[selectedItemIndex]).catObjsNames; catGuids = ((catInfo) allTiles[selectedItemIndex]).catGuidNames; ShowLineHelpers(isShowLineHelpers = false); currentFilter = ""; lastFilter = "__________Q#*(&(*#@&$"; } if(!comboBoxControl.isClickedComboButton) { // if(currentFilter!="") GUIObjsCollider = new Rect(0, 0, 128, catGoes.Count*130); checkGUIObjsCollider = new Rect(0,0,148,catGoes.Count*125); if(checkGUIObjsCollider.height==0) { checkGUIObjsCollider = new Rect(0,0,148,50); } if(catGoes.Count==0) { GUI.Label(new Rect(10,60,100,30),"NO ITEMS"); } scrollPosition = GUI.BeginScrollView(new Rect(0, 60, 145, Screen.height-100), scrollPosition, GUIObjsCollider); int startDrawPoint = (int) (scrollPosition.y/122); int endDrawPoint; if(startDrawPoint<-1) { startDrawPoint = 0; } if(catGoes.Count-startDrawPoint>=7) { endDrawPoint = startDrawPoint + 7; } else { endDrawPoint = startDrawPoint + (catGoes.Count-startDrawPoint); } GUI.Box(GUIObjsCollider,""); for(int i=startDrawPoint;i<endDrawPoint;i++) { if(i>=0&&i<catGoes.Count && (GameObject) catGoes[i]) { if((Texture2D)catPrevs[i]) { previewObjTexture = (Texture2D) catPrevs[i]; } if(GUI.Button (new Rect(8,5+(i*122),115,115),previewObjTexture)) { uMBE.StepOne(); if(currentTile) { Destroy(currentTile); } if(((GameObject)catGoes[i]).transform.parent.gameObject.name.Equals("static_objs")) { isCurrentStatic = true; } else { isCurrentStatic = false; } currentTile = (GameObject) Instantiate((GameObject)catGoes[i],new Vector3(0.0f,0.0f,0.0f),((GameObject)catGoes[i]).transform.rotation); uteTagObject tempTag = (uteTagObject) currentTile.AddComponent<uteTagObject>(); tempTag.objGUID = catGuids[i].ToString(); tempTag.isStatic = isCurrentStatic; currentTile.AddComponent<Rigidbody>(); currentTile.GetComponent<Rigidbody>().useGravity = false; currentTile.GetComponent<BoxCollider>().size -= new Vector3(0.0000001f,0.0000001f,0.0000001f); currentTile.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ; currentTile.GetComponent<Collider>().isTrigger = true; currentTile.AddComponent<uteDetectBuildCollision>(); currentTile.layer = 2; currentObjectID = catNames[i].ToString(); currentTile.name = currentObjectID; currentObjectGUID = catGuids[i].ToString(); helpers_CANTBUILD.transform.position = new Vector3(-1000,0,-1000); helpers_CANTBUILD.transform.localScale = currentTile.GetComponent<Collider>().bounds.size + new Vector3(0.1f,0.1f,0.1f); helpers_CANTBUILD.transform.localRotation = currentTile.transform.localRotation; isRotated = 0; isRotatedH = 0; erase = false; } GUI.Label(new Rect(14,7+(i*122),115,60),(string)catNames[i]); if(!previewObjTexture) { GUI.Label(new Rect(18,50+(i*122),115,30),"NO PREVIEW"); } else if(previewObjTexture.width==20) { GUI.Label(new Rect(18,30+(i*122),115,30),"LOADING..."); } } } GUI.EndScrollView(); GUI.Box(new Rect(0,40,130,20),""); Rect checkGUIObjsCollider_2 = new Rect(checkGUIObjsCollider.x,checkGUIObjsCollider.y+40,checkGUIObjsCollider.width,checkGUIObjsCollider.height); if(checkGUIObjsCollider_2.Contains(normalMousePosition)) { GUI.skin = ui; currentFilter = GUI.TextField(new Rect(4,40,122,19),currentFilter); } else { GUI.Label(new Rect(4,38,122,20),"search: "+currentFilter); } if(currentFilter!=lastFilter) { lastFilter = currentFilter; using(catInfo FilteredCatInfo = new catInfo(allTiles[selectedItemIndex].catName,allTiles[selectedItemIndex].catLayer,allTiles[selectedItemIndex].catCollision)) { FilteredCatInfo.catObjs = new List<GameObject>(); FilteredCatInfo.catObjsPrevs = new List<Texture2D>(); FilteredCatInfo.catObjsNames = new List<string>(); FilteredCatInfo.catGuidNames = new List<string>(); for(int i=0;i<allTiles[selectedItemIndex].catObjs.Count;i++) { FilteredCatInfo.catObjs.Add(allTiles[selectedItemIndex].catObjs[i]); } for(int i=0;i<allTiles[selectedItemIndex].catObjsPrevs.Count;i++) { FilteredCatInfo.catObjsPrevs.Add(allTiles[selectedItemIndex].catObjsPrevs[i]); } for(int i=0;i<allTiles[selectedItemIndex].catObjsNames.Count;i++) { FilteredCatInfo.catObjsNames.Add(allTiles[selectedItemIndex].catObjsNames[i]); } for(int i=0;i<allTiles[selectedItemIndex].catGuidNames.Count;i++) { FilteredCatInfo.catGuidNames.Add(allTiles[selectedItemIndex].catGuidNames[i]); } for(int i=FilteredCatInfo.catObjsNames.Count-1;i>=0;i--) { if(!FilteredCatInfo.catObjsNames[i].Contains(currentFilter)) { FilteredCatInfo.catObjs.RemoveAt(i); FilteredCatInfo.catObjsPrevs.RemoveAt(i); FilteredCatInfo.catObjsNames.RemoveAt(i); FilteredCatInfo.catGuidNames.RemoveAt(i); } } if(currentFilter!="") { catGoes = ((catInfo) FilteredCatInfo).catObjs; catPrevs = ((catInfo) FilteredCatInfo).catObjsPrevs; catNames = ((catInfo) FilteredCatInfo).catObjsNames; catGuids = ((catInfo) FilteredCatInfo).catGuidNames; } else { catGoes = ((catInfo) allTiles[selectedItemIndex]).catObjs; catPrevs = ((catInfo) allTiles[selectedItemIndex]).catObjsPrevs; catNames = ((catInfo) allTiles[selectedItemIndex]).catObjsNames; catGuids = ((catInfo) allTiles[selectedItemIndex]).catGuidNames; } } } } else { if(currentTile) { Destroy(currentTile); } } } } } if(is2D) { if(GUI.Button(new Rect(Screen.width-505,Screen.height-40,130,40),"Reset Camera")) { ResetCamera(); } } else { if(GUI.Button(new Rect(Screen.width-505,Screen.height-40,130,40),"Camera box")) { if(isShowCameraOptions) { isShowCameraOptions = false; } else { isShowCameraOptions = true; } } } if(GUI.Button (new Rect(Screen.width-370,Screen.height-40,70,40),"Eraser")) { if(currentTile) { Destroy(currentTile); helpers_CANTBUILD.transform.position = new Vector3(-1000000.0f,0.0f,-1000000.0f); ShowLineHelpers(isShowLineHelpers = false); } erase = true; } if(GUI.Button(new Rect(Screen.width-295,Screen.height-40,100,40),"Grid Up")) { StartCoroutine(gridSmoothMove(grid,true,cameraMove.gameObject)); } if(GUI.Button(new Rect(Screen.width-195,Screen.height-40,100,40),"Grid Down")) { StartCoroutine(gridSmoothMove(grid,false,cameraMove.gameObject)); } if(currentTile&&!isBuildingTC) { GUI.Box(new Rect(Screen.width-100,200,100,90),"Randomizer"); if(GUI.Button(new Rect(Screen.width-95,220,90,30),"Tile: "+ReturnCondition(isTileRandomizerEnabled))) { if(isTileRandomizerEnabled) { isTileRandomizerEnabled = false; } else { isTileRandomizerEnabled = true; } } if(GUI.Button(new Rect(Screen.width-95,250,90,30),"Rot: "+ReturnCondition(isTileRandomizerRotationEnabled))) { if(isTileRandomizerRotationEnabled) { isTileRandomizerRotationEnabled = false; } else { isTileRandomizerRotationEnabled = true; } } GUI.Box(new Rect(Screen.width-100,40,100,150),"Tile Settings"); if(GUI.Button(new Rect(Screen.width-90,60,40,30),"<-")) { StartCoroutine(smoothRotate(currentTile,new Vector3(0.0f,-10.0f,0.0f),true)); } if(GUI.Button(new Rect(Screen.width-50,60,40,30),"->")) { StartCoroutine(smoothRotate(currentTile,new Vector3(0.0f,10.0f,0.0f),true)); } if(GUI.Button(new Rect(Screen.width-90,90,40,30),"Up")) { StartCoroutine(smoothRotate(currentTile,new Vector3(-10.0f,0.0f,0.0f),false)); } if(GUI.Button(new Rect(Screen.width-50,90,40,30),"Dw")) { StartCoroutine(smoothRotate(currentTile,new Vector3(10.0f,0.0f,0.0f),false)); } if(GUI.Button(new Rect(Screen.width-90,120,80,30),"INVERT")) { StartCoroutine(smoothRotate(currentTile,new Vector3(0.0f,0.0f,20.0f),false)); } if(GUI.Button (new Rect(Screen.width-90,150,80,30),"Cancel")) { if(currentTile) { Destroy(currentTile); ShowLineHelpers(isShowLineHelpers = false); helpers_CANTBUILD.transform.position = new Vector3(-1000000.0f,0.0f,-1000000.0f); } erase = false; } } string buildMode = "Standard"; if(isContinuesBuild) { buildMode = "Continuous"; } else if(isBuildingMass) { buildMode = "Mass"; } if(!isBuildingTC) { if(GUI.Button(new Rect(480,0,210,40),"Build Mode: "+buildMode)) { SwitchBuildMode(); } } if(GUI.Button(new Rect(0,Screen.height-40,130,40),"SAVE")) { StartCoroutine(LayersEngine.ReSaveMap()); } if(isItNewPattern) { if(GUI.Button (new Rect(140,Screen.height-40,80,40),"Export")) { if(currentTile) Destroy(currentTile); exporter.isShow = true; } } if(GUI.Button(new Rect(Screen.width-100,0,100,40),"OPTIONS")) { if(uteOptions.isShow) { uteOptions.isShow = false; } else { uteOptions.isShow = true; } } if(GUI.Button(new Rect(Screen.width-200,0,90,40),"HELP")) { if(uteHelp.isShow) { uteHelp.isShow = false; } else { uteHelp.isShow = true; } } }
private IEnumerator ReloadCatAssetPreviewInSlowMode(catInfo _ci) { catInfo ci = (catInfo) _ci; for(int j=0;j<ci.catObjsPrevs.Count;j++) { Texture2D _oldTex = ci.catObjsPrevs[j]; if(_oldTex.width==20&&_oldTex.height==20) { for(int i=0;i<25;i++) { Object _obj = (Object) ci.catObjs[j]; string opath = UnityEditor.AssetDatabase.GUIDToAssetPath(_obj.name); GameObject tGO = (GameObject) UnityEditor.AssetDatabase.LoadMainAssetAtPath(opath); Texture2D _tex = (Texture2D) UnityEditor.AssetPreview.GetAssetPreview(tGO); if(_tex!=null) { Texture2D newTex = new Texture2D(_tex.width,_tex.height); newTex.LoadImage(_tex.EncodeToPNG()); ci.catObjsPrevs[j] = newTex; break; } else { yield return 0; } } } } yield return 0; }