Not finished!! Expected to be completed before August 29
Game Effect Show
Achieve results
Make a scene, game prefab
Shadow hidden Camera small icon
(Click Shadow Camera Small icon)
Create a new Sprite, add a doughnut picture
(The value of the modified scale is 0.45)
Set the donut as a preset
With doughnuts, making chocolate into a prefab
(Modify the value of scale to 0.65 and set the order in layer to a value of-1)
And make chocolate into a preset.
Create a game background
(The game background can be set slightly larger, anti-exposure)
Create a game manager
Create Gameobject objects, add Gamemanager scripts, mount to Gameobject
usingSystem.Collections;usingSystem.Collections.Generic;usingUnityengine; Public classGamemanager:monobehaviour {//Single Case Private StaticGamemanager _instance; Public StaticGamemanager Instance {Get { return_instance; } Set{_instance=value; } } Private voidAwake () {_instance= This; } //Use this for initialization voidStart () {}//Update is called once per frame voidUpdate () {}}
GameManager.cs
Create a single case
Private Static Gamemanager _instance;
Public Static Gamemanager Instance { get { return _instance; } Set { = value; } }
(using shortcut keys to generate a singleton method Ctrl+r+e)
Game initialization function
Private void Awake () { this; }
Add a reference to the game manager, set the grid game to the row
Public int Xcolumn; Public int Yrow;
Add a chocolate reference
Public Gameobject Gridprefab;
Creating chocolate in a game scene
void Start () { for (int0; x < Xcolumn; + +) { for ( int y=0; y<yrow;y++) { = instantiate (Gridprefab,new Vector3 (x, Y,0), quaternion.identity ); // chocolate rotates with transform parent object chocolate.transform.SetParent (transform); }}}
Run the program
(Set the order in layer of the game background to-2)
Correcting background position
Unity3d_ (game) dessert 01_ production Props