コード例 #1
0
        /// <summary>
        /// Automatically activate tile system from user selection if appropriate so that
        /// tool can be selected.
        /// </summary>
        private void AutoActivateTileSystem()
        {
            ToolUtility.SelectActiveOrParentTileSystem();

            if (ToolUtility.ActiveTileSystem == null)
            {
                // Okay, no tile system is actually selected.
                // Select first non-locked if possible; otherwise select first if possible.
                var tileSystems     = ToolUtility.GetAllTileSystemsInScene();
                var firstTileSystem = tileSystems.FirstOrDefault(s => s != null && !s.Locked);
                if (firstTileSystem == null)
                {
                    firstTileSystem = tileSystems.FirstOrDefault(s => s != null);
                }

                if (firstTileSystem != null)
                {
                    ToolUtility.SelectTileSystem(firstTileSystem);
                }
                else
                {
                    return;
                }
            }

            // When using a tool it only makes sense to have one selected tile system.
            if (Selection.objects.Length > 1)
            {
                Selection.objects = new Object[] { ToolUtility.ActiveTileSystem.gameObject };
            }
        }