void Inspector_Tile() { using (new GUIBackgroundColorScope(Color.cyan)) { refTile = (IsoTile)EditorGUILayout.ObjectField(refTile, typeof(IsoTile), allowSceneObjects: true); } using (new EditorGUILayout.HorizontalScope()) { { using (new GUIBackgroundColorScope(Color.cyan)) { //refTile = (IsoTile)EditorGUI.ObjectField(GUILayoutUtility.GetRect(70, 40), refTile, typeof(IsoTile), allowSceneObjects:true); EditorGUI.BeginDisabledGroup(refTile == null); if (GUILayout.Button("Copycat")) { for (int i = 0; i < Selection.gameObjects.Length; ++i) { Selection.gameObjects[i].GetComponent <IsoTile>().Copycat(refTile); } } EditorGUI.EndDisabledGroup(); } } using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightYellow)) { if (GUILayout.Button("Duplicate")) { List <GameObject> _selection = new List <GameObject>(); for (int i = 0; i < Selection.gameObjects.Length; ++i) { _selection.Add(( Selection.gameObjects[i].GetComponent <IsoTile>()).Duplicate().gameObject); } Undo.RecordObjects(Selection.objects, "IsoTile:Dulicate"); Selection.objects = _selection.ToArray(); } } using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightMagenta)) { if (GUILayout.Button("Select (B)ulk")) { Selection.activeGameObject = _tile_Inspector.Bulk.gameObject; } } } EditorGUILayout.Separator(); EditorGUILayout.LabelField(string.Format( "Grid's Tile Scale : Width({0:0.00}), Height({1:0.00})", _tile_Inspector.coordinates.grid.TileSize.x, _tile_Inspector.coordinates.grid.TileSize.y)); float fWidth = EditorGUIUtility.currentViewWidth * 0.25f; using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Auto Fit", GUILayout.MaxWidth(fWidth)); EditorGUI.BeginChangeCheck(); EditorGUILayout.ToggleLeft("Collider", _tile_Inspector.bAutoFit_ColliderScale, GUILayout.MaxWidth(fWidth)); if (EditorGUI.EndChangeCheck()) { bool _bTmp = !_tile_Inspector.bAutoFit_ColliderScale; for (int i = 0; i < Selection.gameObjects.Length; ++i) { if (Selection.gameObjects[i] != null) { IsoTile _tTmp = Selection.gameObjects[i].GetComponent <IsoTile>(); if (_tTmp != null) { Undo.RecordObject(_tTmp, "Use AutoFit Collider"); _tTmp.bAutoFit_ColliderScale = _bTmp; _tTmp.GetComponent <RegularCollider>().Toggle_UseGridTileScale(_bTmp); } } } } EditorGUI.BeginChangeCheck(); EditorGUILayout.ToggleLeft("Sprite", _tile_Inspector.bAutoFit_SpriteSize, GUILayout.MaxWidth(fWidth)); if (EditorGUI.EndChangeCheck()) { bool _bTmp = !_tile_Inspector.bAutoFit_SpriteSize; for (int i = 0; i < Selection.gameObjects.Length; ++i) { if (Selection.gameObjects[i] != null) { IsoTile _tTmp = Selection.gameObjects[i].GetComponent <IsoTile>(); if (_tTmp != null) { Undo.RecordObject(_tTmp, "Use AutoFit Iso2DObject"); _tTmp.bAutoFit_SpriteSize = _bTmp; _tTmp.Update_Attached_Iso2DScale(); } } } } } EditorGUILayout.Separator(); EditorGUI.indentLevel = 0; }
void Inspector_Side() { EditorGUILayout.Separator(); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("[Side Control]", EditorStyles.boldLabel, GUILayout.MaxWidth(120)); using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightBlue)) { EditorGUI.BeginChangeCheck(); bool _bUnionMode = 1 == EditorGUILayout.Popup( _tile_Inspector.GetComponent <IsoTile>().IsUnionCube() ? 1 : 0, new string[] { "Side Mode", " Union Mode" }); if (EditorGUI.EndChangeCheck()) { foreach (GameObject _go in Selection.objects) { if (_go == null) { continue; } IsoTile _t = _go.GetComponent <IsoTile>(); if (_t != null && _t.IsUnionCube() != _bUnionMode) { _t.Reset_SideObject(_bUnionMode); } } } } } EditorGUILayout.Separator(); using (new EditorGUILayout.HorizontalScope()) { float fWidth = EditorGUIUtility.currentViewWidth / 3f; Rect _Rect = EditorGUILayout.GetControlRect( new GUILayoutOption[] { GUILayout.Height(fWidth), GUILayout.ExpandWidth(true) }); Rect[] _DescRectDivision; Rect[] _SubRects; if (_tile_Inspector.IsUnionCube()) { Iso2DObject _Union = _tile_Inspector.GetSideObject(Iso2DObject.Type.Side_Union); if (_Union != null) { SpriteRenderer sprr = _Union.sprr; _DescRectDivision = _Rect.Division( new float[] { 0.25f / 8f, 2.75f / 8f, 1 / 8f, 3f / 8f, 1f / 8f }, null); _SubRects = _DescRectDivision[1].Division(null, new float[] { 0.05f, 0.35f, 0.6f }); Union_Field(_SubRects[1], "Union Sprite", _Union, Handles.selectedColor); Util.CustomEditorGUI.DrawSprite(_SubRects[2].Division(new float[] { 0.25f, 0.5f }, null)[1], IsoMap.instance.IsoTile_Union_OutlineImage, Color.clear, true, false); CustomEditorGUI.DrawSideSprite(_DescRectDivision[3], _Union, false, false); } } else { _DescRectDivision = _Rect.Division( new float[] { 0.5f / 8f, 2.5f / 8f, 1f / 8f, 3 / 8f, 1f / 8f }, null); _SubRects = _DescRectDivision[1].Division(null, new float[] { 2 / 10f, 2 / 10f, 2 / 10f, 2 / 10f, 2 / 10f }); _Rect = _DescRectDivision[3].Division(new float[] { 0.1f, 0.8f }, new float[] { 0.2f, 0.8f })[3]; Util.CustomEditorGUI.DrawSprite(_Rect, IsoMap.instance.IsoTile_Side_OutlineImage, Color.clear, false, false); Iso2DObject _Iso2D_x = Side_Field(_SubRects[0], Iso2DObject.Type.Side_X, Handles.xAxisColor, IsoMap.instance.Side_X_Prefab); Iso2DObject _Iso2D_y = Side_Field(_SubRects[2], Iso2DObject.Type.Side_Y, Handles.yAxisColor, IsoMap.instance.Side_Y_Prefab); Iso2DObject _Iso2D_z = Side_Field(_SubRects[4], Iso2DObject.Type.Side_Z, Handles.zAxisColor, IsoMap.instance.Side_Z_Prefab); CustomEditorGUI.DrawSideSprite(_Rect, _Iso2D_y, false, false); CustomEditorGUI.DrawSideSprite(_Rect, _Iso2D_x, false, false); CustomEditorGUI.DrawSideSprite(_Rect, _Iso2D_z, false, false); } } EditorGUILayout.Space(); EditorGUILayout.Space(); }
void Inspector_Tile() { using (new GUIBackgroundColorScope(Color.cyan)) { refTile = (IsoTile)EditorGUILayout.ObjectField(refTile, typeof(IsoTile), allowSceneObjects: true); } using (new EditorGUILayout.HorizontalScope()) { CustomEditorGUI.Button(refTile != null, Color.cyan, "Copycat", () => { for (int i = 0; i < targets.Length; ++i) { ((IsoTile)targets[i]).Copycat(refTile); } }); CustomEditorGUI.Button(true, CustomEditorGUI.Color_LightYellow, "Duplicate", () => { List <GameObject> _selection = new List <GameObject>(); for (int i = 0; i < targets.Length; ++i) { _selection.Add(((IsoTile)targets[i]).Duplicate().gameObject); } Undo.RecordObjects(Selection.objects, "IsoTile:Dulicate"); Selection.objects = _selection.ToArray(); }); CustomEditorGUI.Button(true, CustomEditorGUI.Color_LightMagenta, "Select Bulk", () => { Selection.activeGameObject = _tile_Inspector.Bulk.gameObject; }); } using (new EditorGUILayout.HorizontalScope()) { CustomEditorGUI.Button(true, Color.magenta, "Split bulk with selected tiles.", () => { var newbulk = IsoMap.instance.NewBulk(_tile_Inspector.Bulk, targets.Where(r => r != null && r is IsoTile).Cast <IsoTile>()); }); } EditorGUILayout.Separator(); EditorGUILayout.LabelField(string.Format( "Grid's Tile Scale : Width({0:0.00}), Height({1:0.00})", _tile_Inspector.coordinates.grid.TileSize.x, _tile_Inspector.coordinates.grid.TileSize.y)); float fWidth = EditorGUIUtility.currentViewWidth * 0.25f; using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Auto Fit", GUILayout.MaxWidth(fWidth)); EditorGUI.BeginChangeCheck(); EditorGUILayout.ToggleLeft("Collider", _tile_Inspector.bAutoFit_ColliderScale, GUILayout.MaxWidth(fWidth)); if (EditorGUI.EndChangeCheck()) { bool _bTmp = !_tile_Inspector.bAutoFit_ColliderScale; for (int i = 0; i < Selection.gameObjects.Length; ++i) { if (Selection.gameObjects[i] != null) { IsoTile _tTmp = Selection.gameObjects[i].GetComponent <IsoTile>(); if (_tTmp != null) { Undo.RecordObject(_tTmp, "Use AutoFit Collider"); _tTmp.bAutoFit_ColliderScale = _bTmp; _tTmp.GetComponent <RegularCollider>().Toggle_UseGridTileScale(_bTmp); } } } } EditorGUI.BeginChangeCheck(); EditorGUILayout.ToggleLeft("Sprite", _tile_Inspector.bAutoFit_SpriteSize, GUILayout.MaxWidth(fWidth)); if (EditorGUI.EndChangeCheck()) { bool _bTmp = !_tile_Inspector.bAutoFit_SpriteSize; for (int i = 0; i < Selection.gameObjects.Length; ++i) { if (Selection.gameObjects[i] != null) { IsoTile _tTmp = Selection.gameObjects[i].GetComponent <IsoTile>(); if (_tTmp != null) { Undo.RecordObject(_tTmp, "Use AutoFit Iso2DObject"); _tTmp.bAutoFit_SpriteSize = _bTmp; _tTmp.Update_Attached_Iso2DScale(); } } } } } EditorGUILayout.Separator(); EditorGUI.indentLevel = 0; }