Added GrassTile Prefab and Simple TileController
This commit is contained in:
parent
84c1b1f2df
commit
eeaf7cc11d
5 changed files with 153 additions and 130 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
|
@ -5,14 +6,26 @@ using UnityEngine;
|
|||
public class TileController : MonoBehaviour
|
||||
{
|
||||
public GameObject tile;
|
||||
|
||||
public GameObject CameraGameObject;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
for (int x = 0; x < 10; x++)
|
||||
Camera camera = CameraGameObject.GetComponent<Camera>();
|
||||
Vector3 screen = camera.ViewportToWorldPoint(new Vector3(1,1,camera.nearClipPlane));
|
||||
int x = Convert.ToInt32(Math.Ceiling(screen.x));
|
||||
int y = Convert.ToInt32(Math.Ceiling(screen.y));
|
||||
|
||||
Debug.Log(screen);
|
||||
for (int xx = -x; xx <= x; xx++)
|
||||
{
|
||||
for (int y = 0; y < 10; y++)
|
||||
for (int yy = -y; yy <= y; yy++)
|
||||
{
|
||||
//Instantiate(tile, new Vector3(x, y, 0), Quaternion.identity);
|
||||
if (tile != null)
|
||||
{
|
||||
Instantiate(tile, new Vector3(xx, yy, 0), Quaternion.identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue