private void InitGridInfomation(GridLayout gridLayout) { if (mapObjLayerHolder == null) { mapObjLayerHolder = gridLayout.GetComponent <LJMapObjLayerHolder>(); } }
void OnDrawSceneGUI(SceneView sceneView) { LJMapObjLayerHolder mapObjLayerHolder = prefabBrush.LJMapObjLayerHolder; if (mapObjLayerHolder == null) { return; } Grid grid = mapObjLayerHolder.GetComponent <Grid>(); if (grid == null) { return; } LJMapObjLayerData mapObjLayerData = mapObjLayerHolder.mapObjLayerData; if (mapObjLayerData == null) { return; } if (!prefabBrush.showObjLayerBorder && !prefabBrush.showObjLayerInfo) { return; } Vector3 cellSize = grid.cellSize; //Debug.Log("we got cellSize : "+ cellSize); LJMapObjDict dict = mapObjLayerData.PositionProperties; StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <SerVector2Int, LJMapObject> kvp in dict) { SerVector2Int serCellPosInt = kvp.Key; Vector2Int cellPosInt = MapUtil.ConvertSerVec2Int2Vec2Int(serCellPosInt); LJMapObject ljGridObject = kvp.Value; Vector3[] cellCorners = MapUtil.GetMapWorldCorners(new Vector3Int(cellPosInt.x, cellPosInt.y, 0), grid); Handles.color = Color.cyan; if (prefabBrush.showObjLayerBorder) { Handles.DrawLines(new Vector3[] { cellCorners[0], cellCorners[2], cellCorners[2], cellCorners[1], cellCorners[1], cellCorners[3], cellCorners[3], cellCorners[0], }); } //switch (ljGridObject.d) if (ljGridObject == null) { continue; } if (!prefabBrush.showObjLayerInfo) { continue; } stringBuilder.Remove(0, stringBuilder.Length); switch (ljGridObject.MainType) { case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE: stringBuilder.Append("未定义"); break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER: stringBuilder.Append("域都"); break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.CITY: stringBuilder.Append("卫都"); break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.GATE: stringBuilder.Append("关隘"); break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN: stringBuilder.Append("城镇"); break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE: stringBuilder.Append("资源区"); break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE: stringBuilder.Append("讨伐区"); break; } switch (ljGridObject.MainType) { case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE: break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER: case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.CITY: case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.GATE: switch (ljGridObject.SubType) { case LJMapConst.MAP_OBJ_SUB_TYPE.UNDEFINE: stringBuilder.Append(" 未定义 "); break; case LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_OUTSIDE: stringBuilder.Append(" 外层 "); break; case LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_INNER: stringBuilder.Append(" 内层 "); break; case LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_KERNEL: stringBuilder.Append(" 核心 "); break; case LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_UNUSERD: stringBuilder.Append(" 阻塞 "); break; case LJMapConst.MAP_OBJ_SUB_TYPE.PART: break; } break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN: //stringBuilder.AppendFormat("id : {0}", ljGridObject.GetGridObjectId()); break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE: //stringBuilder.AppendFormat("id : {0}", ljGridObject.MainId); break; case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE: //stringBuilder.AppendFormat("id : {0}", ljGridObject.MainId); break; } stringBuilder.AppendFormat("id : {0}", ljGridObject.GetGridObjectId()); Handles.color = Color.green; Handles.Label(cellCorners[4], stringBuilder.ToString(), GUI.skin.customStyles[4]); } }
public override void OnPaintInspectorGUI() { base.OnPaintInspectorGUI(); bool isChanged = false; EditorGUILayout.LabelField("蓝鲸图块编辑"); List <Vector3Int> allLocations = new List <Vector3Int>(); Vector3Int lastCellposition = lastBoundsInt.position; allLocations.Add(lastCellposition); foreach (Vector3Int location in lastBoundsInt.allPositionsWithin) { if (lastCellposition.Equals(location)) { continue; } allLocations.Add(location); } DrawInspectorAllLocation(allLocations); LJMapObjLayerHolder mapObjLayerHolder = prefabBrush.LJMapObjLayerHolder; if (mapObjLayerHolder == null) { EditorGUILayout.LabelField("未绑定 LJ Map Obj Layer Holder!"); return; } LJMapObjLayerData mapObjLayerData = mapObjLayerHolder.mapObjLayerData; if (mapObjLayerData == null) { EditorGUILayout.LabelField("未加载地图!"); return; } SerVector2Int lastCellVectPosition = new SerVector2Int(allLocations[0].x, allLocations[0].y); //SerVector3Int lastCellVectPosition = MapUtil.ConvertVec3Int2SerVec3Int(allLocations[0]); LJMapObject currentGirdObject = mapObjLayerData.GetPositionProperty(lastCellVectPosition); int drawSt = DrawInspectorEnableGirdObject(mapObjLayerData, currentGirdObject, allLocations); switch (drawSt) { case 1: //有修改 已关闭 SaveLJMapObjLayerData(mapObjLayerData); return; case 2: //有修改 已开启 currentGirdObject = mapObjLayerData.GetPositionProperty(lastCellVectPosition); isChanged = true; break; case 3: // 无修改 关闭 return; case 4: // 无修改 开启 break; } DrawAllGirdObjectType(mapObjLayerData, currentGirdObject, allLocations, ref isChanged); //switch (currentGirdObject.MainType) //{ // case LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE: // break; // case LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER: // case LJMapConst.MAP_OBJ_MAIN_TYPE.CITY: // case LJMapConst.MAP_OBJ_MAIN_TYPE.GATE: // case LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN: // case LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE: // case LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE: // //DrawAllGirdObjectMainId(gridMapData, currentGirdObject, allLocations,ref isChanged); // break; //} //switch (currentGirdObject.MainType) //{ // case LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE: // break; // case LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER: // case LJMapConst.MAP_OBJ_MAIN_TYPE.CITY: // case LJMapConst.MAP_OBJ_MAIN_TYPE.GATE: // DrawAllGirdObjectSubId(gridMapData, currentGirdObject, allLocations,ref isChanged); // break; // case LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN: // case LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE: // case LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE: // break; //} //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PrefixLabel("扩展信息 : "); //ljGridObject.ExtendMsg = EditorGUILayout.DelayedTextField(ljGridObject.ExtendMsg); //EditorGUILayout.EndHorizontal(); //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PrefixLabel("名字 : "); //ljGridObject.Name = EditorGUILayout.DelayedTextField(ljGridObject.Name); //EditorGUILayout.EndHorizontal(); //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PrefixLabel("备注 : "); //ljGridObject.Info = EditorGUILayout.DelayedTextField(ljGridObject.Info); //EditorGUILayout.EndHorizontal(); if (isChanged) { SaveLJMapObjLayerData(mapObjLayerData); } }