Ejemplo n.º 1
0
        public void SetDimensions(int width, int height)
        {
            int size = width * height;

            if (size > 0 && size * 4 < 65000) //NOTE: 65000 is the current maximum vertex allowed per mesh and each tile has 4 vertex
            {
                this.width    = width;
                this.height   = height;
                tileData_list = Enumerable.Repeat(TileSetConst.TileData_Empty, size).ToList();
            }
            else
            {
                LogCat.warn("Invalid parameters!");
            }
        }
Ejemplo n.º 2
0
        public static void Test()
        {
            List <TmpStruct> data_list = new List <TmpStruct>();

            data_list.Add(new TmpStruct(3, "a", 5, "f1"));
            data_list.Add(new TmpStruct(2, "b", 1, "f2"));
            data_list.Add(new TmpStruct(4, "c", 6, "f6"));
            data_list.Add(new TmpStruct(4, "c", 6, "f3"));
            data_list.Add(new TmpStruct(2, "d", 2, "f4"));
            data_list.Add(new TmpStruct(3, "a", 4, "f5"));

            var compareRules = new List <Comparison <TmpStruct> >()
            {
                CompareRule1, CompareRule2, CompareRule3
            };

            data_list.SortWithCompareRules(compareRules);
            LogCat.warn(data_list);
        }
Ejemplo n.º 3
0
 protected override void OnFail()
 {
     base.OnFail();
     LogCat.warn("服务器连接失败[未启动?]", www.url, www.error);
     Broadcast(null, AssetBundleEventNameConst.On_ResourceWebRequester_Fail, this);
 }
Ejemplo n.º 4
0
 public static void ShowNotificationAndWarn(this EditorWindow self, params object[] args)
 {
     self._ShowNotificationAndCallback(() => LogCat.warn(args), args);
 }
        public void DisplayTileSetBrush()
        {
            var  e = Event.current;
            bool is_mouse_inside_tileSetBrush_palette_scroll_area =
                e.isMouse && tileSetBrush_palette_scroll_area_rect.Contains(e.mousePosition);

            using (new EditorGUILayoutBeginHorizontalScope())
            {
                string tileSetBrushId_label = tileSet.selected_tileSetBrushId > 0
        ? string.Format("(id:{0})", tileSet.selected_tileSetBrushId)
        : "";
                EditorGUILayout.LabelField("TileSetBrush Palette" + tileSetBrushId_label, EditorStyles.boldLabel);
                is_display_tileSetBrush_reordableList =
                    GUILayoutUtil.ToggleButton("Display List", is_display_tileSetBrush_reordableList);
            }

//    tileSet.tileSetBrush_type_mask = EditorGUILayout.MaskField("TileSetBrush Mask", tileSet.tileSetBrush_type_mask,
//      tileSet.GetTileSetBrushTypeArray());

            int column_count = (int)(tile_scroll_size_rect.width / (tileSet.visual_tile_size.x + visual_tile_padding));

            if (column_count <= 0)
            {
                column_count = 1;
            }
            float tileSetBrushes_scroll_max_height = Screen.height / 4;
            //commented because m_rTileScrollSize.width.height was changed to Screen.height;  fBrushesScrollMaxHeight -= fBrushesScrollMaxHeight % 2; // sometimes because size of tile scroll affects size of brush scroll, the height is dancing between +-1, so this is always taking the pair value
            float tileSetBrush_palette_scroll_area_height = Mathf.Min(tileSetBrushes_scroll_max_height,
                                                                      4 + (tileSet.visual_tile_size.y + visual_tile_padding) * (1 + (tileSet.tileSetBrush_list.Count / column_count)));

            using (new EditorGUILayoutBeginVerticalScope(GUILayout.MinHeight(tileSetBrush_palette_scroll_area_height)))
            {
                if (is_display_tileSetBrush_reordableList)
                {
                    DisplayTileSetBrushReorderableList();
                }
                else
                {
                    bool    is_refresh_tileSetBrushList = false;
                    Vector2 tileSetBrushes_scroll_pos   = sharedTileSetData.tileSetBrushes_scroll_pos;
                    using (new EditorGUILayoutBeginScrollViewScope(ref tileSetBrushes_scroll_pos, GUIStyleConst.Scroll_Style))
                    {
                        if (is_update_scroll_pos)
                        {
                            sharedTileSetData.tileSetBrushes_scroll_pos = tileSetBrushes_scroll_pos;
                        }

                        Rect scroll_view_rect = new Rect(0, 0, tile_scroll_size_rect.width, 0);
                        column_count =
                            Mathf.Clamp((int)scroll_view_rect.width / (int)(tileSet.visual_tile_size.x + visual_tile_padding), 1,
                                        column_count);
                        if (tileSet.tileSetBrush_list != null)
                        {
                            GUILayout.Space((tileSet.visual_tile_size.y + visual_tile_padding) *
                                            (1 + (tileSet.tileSetBrush_list.Count - 1) / column_count));
                            for (int i = 0, index = 0; i < tileSet.tileSetBrush_list.Count; ++i, ++index)
                            {
                                var tileSetBrushContainer = tileSet.tileSetBrush_list[i];
                                if (tileSetBrushContainer.tileSetBrush == null || tileSetBrushContainer.tileSetBrush.tileSet != tileSet)
                                {
                                    is_refresh_tileSetBrushList = true;
                                    continue;
                                }

                                if (!tileSetBrushContainer.tileSetBrush.is_show_in_palette ||
                                    !tileSet.IsTileSetBrushVisibleByTypeMask(tileSetBrushContainer.tileSetBrush))
                                {
                                    --index;
                                    continue;
                                }

                                int  tile_x           = index % column_count;
                                int  tile_y           = index / column_count;
                                Rect visual_tile_rect = new Rect(2 + tile_x * (tileSet.visual_tile_size.x + visual_tile_padding),
                                                                 2 + tile_y * (tileSet.visual_tile_size.y + visual_tile_padding), tileSet.visual_tile_size.x,
                                                                 tileSet.visual_tile_size.y);
                                //Fix Missing Tileset reference
                                if (tileSetBrushContainer.tileSetBrush.tileSet == null)
                                {
                                    LogCat.warn(string.Format("Fixed missing tileset reference in brush {0}  Id({1})",
                                                              tileSetBrushContainer.tileSetBrush.name, tileSetBrushContainer.id));
                                    tileSetBrushContainer.tileSetBrush.tileSet = tileSet;
                                }

                                uint tileData = TileSetConst.TileData_Empty;
                                if (tileSetBrushContainer.tileSetBrush.IsAnimated())
                                {
                                    tileData = tileSetBrushContainer.tileSetBrush.GetAnimTileData();
                                }
                                else
                                {
                                    tileData = tileSetBrushContainer.tileSetBrush.PreviewTileData();
                                }
                                TileSetEditor.DoGUIDrawTileFromTileData(visual_tile_rect, tileData, tileSet,
                                                                        tileSetBrushContainer.tileSetBrush.GetAnimUV());
                                if ((is_left_mouse_released || is_right_mouse_released || mouseDoubleClick.IsDoubleClick) && //左键放开,右键放开,双击鼠标
                                    is_mouse_inside_tileSetBrush_palette_scroll_area && visual_tile_rect.Contains(Event.current.mousePosition))//点钟该区域
                                {
                                    tileSet.selected_tileSetBrushId = tileSetBrushContainer.id;
                                    RemoveTileSelection();
                                    if (mouseDoubleClick.IsDoubleClick)
                                    {
                                        EditorGUIUtility.PingObject(tileSetBrushContainer.tileSetBrush);
                                        selected_tileSetBrush_in_inspector = tileSetBrushContainer.tileSetBrush;
                                    }

                                    if (is_right_mouse_released)
                                    {
                                        TilePropertiesEditor.Show(tileSet);
                                    }
                                }
                                else if (tileSet.selected_tileSetBrushId == tileSetBrushContainer.id)
                                {
                                    Rect selection_rect = new Rect(2 + tile_x * (tileSet.visual_tile_size.x + visual_tile_padding),
                                                                   2 + tile_y * (tileSet.visual_tile_size.y + visual_tile_padding),
                                                                   (tileSet.visual_tile_size.x + visual_tile_padding),
                                                                   (tileSet.visual_tile_size.y + visual_tile_padding));
                                    DrawUtil.HandlesDrawSolidRectangleWithOutline(selection_rect, new Color(0f, 0f, 0f, 0.1f),
                                                                                  new Color(1f, 1f, 0f, 1f));
                                }
                            }


                            if (is_refresh_tileSetBrushList)
                            {
                                tileSet.RemoveInvalidTileSetBrushList();
                                tileSet.UpdateTileSetBrushTypeArray();
                            }
                        }
                    }

                    if (e.type == EventType.Repaint)
                    {
                        tileSetBrush_palette_scroll_area_rect = GUILayoutUtility.GetLastRect();
                    }
                }
            }

            if (GUILayout.Button("Import all tileSetBrush_list found in the project"))
            {
                AddAllTileSetBrushesFoundInTheProject(tileSet);
                EditorUtility.SetDirty(tileSet);
            }
        }