• Share this text:
Report Abuse
Ucb.cs - posted by guest on 3rd December 2019 10:45:22 PM

using UnityEngine;

//to

//the cubit group

public class ucb: MonoBehaviour

{

  internal string worldID;

 public Transform cubitPrefab,blankPrefab;

 public int scale=1;

 public bool flat,memory;

 bool built;

 public void Engridden(string status)//GRIDDIFICATION KODE

 {

  if(built)

   return;

  float cubitScale = Mathf.Sqrt(status.Length);

  name = "brickn_" + status;

  float ratio = 1f / (float)cubitScale;

  int ind = 0;

  Vector3 startPos = transform.position - (Vector3.right / 2) - (Vector3.down / 2);

  UnityEngine.UI.GridLayoutGroup isUI = GetComponent<UnityEngine.UI.GridLayoutGroup>();

  if(isUI)

  {

   isUI.constraintCount = (int)cubitScale;

   isUI.cellSize = new Vector2(cubitScale/2,cubitScale/2) *.8f;

  }

  for (int i = 0; i < cubitScale; i++)

  {

   for (int j = 0; j < cubitScale; j++)

   {

     Transform cb = Instantiate(status[ind] == '~'?cubitPrefab:blankPrefab);

     cb.SetParent(transform);

     if (!isUI)

     {

      cb.position = startPos + (Vector3.right * ratio* j) + (Vector3.down * ratio * i);

      cb.transform.localScale = Vector3.one * ratio;

     }

     ind++;

    }

  }

  if (flat)

   transform.Rotate(90, 0, 0);

  transform.localScale = Vector3.one * scale;

  built=true;

 }

}


Report Abuse

Login or Register to edit or copy and save this text. It's free.