csharp 团结/ 2D / dynamic_scene_base_512_tile
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 团结/ 2D / dynamic_scene_base_512_tile相关的知识,希望对你有一定的参考价值。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Board : MonoBehaviour
{
public GameObject TilePrefab;
public int Width;
public int Height;
public int BorderSize;
private Tile[,] _allTiles;
// Use this for initialization
void Start () {
_allTiles = new Tile[Width,Height];
Setup_tiles();
SetupCamera();
}
// Update is called once per frame
void Update () {
}
void Setup_tiles()
{
for( int i = 0; i < Width; i++ )
{
for (int j = 0; j < Height; j++)
{
GameObject tile = Instantiate(TilePrefab, new Vector3(i, j, 0), Quaternion.identity) as GameObject;
tile.name = "Tile(" + i + "," + j + ")";
_allTiles[i, j] = tile.GetComponent<Tile>();
tile.transform.parent = transform;
}
}
}
void SetupCamera()
{
Camera.main.transform.position = new Vector3((float) (Width-1) / 2f,(float)(Height-1)/2f,-10f);
float aspectRatio = (float) Screen.width / (float) Screen.height;
float verticalSize = (float) Height / 2f + (float) BorderSize;
float horizontalSize = ((float) Width / 2f + (float) BorderSize) / aspectRatio;
Camera.main.orthographicSize = (verticalSize> horizontalSize) ? verticalSize : horizontalSize;
}
}
以上是关于csharp 团结/ 2D / dynamic_scene_base_512_tile的主要内容,如果未能解决你的问题,请参考以下文章
csharp 团结/ 2D /速度
csharp 团结/ 2D / dynamic_scene_base_512_tile
csharp 团结/变换/ localscale
csharp 团结/变换/旋转
csharp 团结/变换/翻译
csharp 团结/变换/上/前进/右