This is the 26th day of my participation in the August Text Challenge.More challenges in August

Today inspired by friends: Unity can develop games, can develop animation effects and video.

Before the committee to do the video feel very difficult, I heard that can be done by programming, all of a sudden, it is estimated that it can better present interesting stories to learn programming this column! Let’s do it.

I’ve never used Unity, but as a multilingual Java writer for more than a decade, I don’t think I should be stumped!

First look at the results:

Save you 3 hours to get started developing Unity’s first HelloWorld

As a challenge to learn something new, here’s how.

Install the Unity

I’m using a MacBook Pro: The students downloaded the 2017 UNITY LTS version

Why did you choose this one?

Because it is installed through UnityHub (I installed hub first), the installation prompts about 14GB space to download Unity related files. Another friend showed up with more than 2 gigabytes of Unity 2020 development components installed.

Novice experience can actually pick a simple easy lane, why not a light and fast!

Download the 2017LTS version above.

The installation process is simple, the only important thing here is to select the License. Unity supports Personal learning and use, please remember to select ‘Unity Personal’, the rest is easy to install.

The development of

Create a new 2D project as follows:



After the project is completed, the main interface is as follows:

The interface is left, center, and right.

On the left are scenes, shots, and component management. In the middle is the visualization area, including the game simulation window. On the right is the Inspector/Services TAB, which provides more detailed control of Unity components.

Then the following defaults to: Project and Console

Project is to manage Project files and resources.

Console is a C# program that displays debug logs.

As shown below (the student committee added an AudioMixer by itself)

Initial feeling

It’s only been a while since we entered beginner mode, but don’t take it with a grain of salt.

When I first got into Unity, I was stunned. It looks like AutoCAD/SolidWorks/3DMax. After a bit of fumbling, it also feels like Maybe Unity has a bit more binding scripting and game rendering.

Unity is like this when compared to other development languages:

Learning Unity is like flying an airplane. It gives you a lot of buttons and you can program it, but you need to be familiar with it.

Otherwise you will spend a long time will not find!! (crash)

Learning Java/Python is like riding a bike. You get on the bike and then add things to it. For developers, it is more about exploring and expanding the upper framework of the language, constantly adding peripherals, and finally becoming rich in features. (C++ to do the game engine is very possible)

All right, let’s put aside our feelings and just fumble through some of the documents.

So let’s do the following.

Operating point

Add squares, circles, and text to the home screen.



Add the Sphere (circle) and Quad (square) components.

Below is the block component:

Bind code to block

Go to Inspector and click Add Component in the lower right corner to Add the script (bind our code)



Type Player, then click “Create And Add” :



After the Inspector, we see the following:



Copy the following code into the Player C# script and save it:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Unity is a beginner's demo
public class Player : MonoBehaviour {

	// Use this for initialization
	void Start () {
		Cursor.visible = false;
	}
	
	// Update is called once per frame
	void Update () {
	    // Get the vertical mouse axis
		float y = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
		// Keep the X-axis of the current component unchanged, and the Y-axis moves with the mouse, i.e., up and down in place.
		this.transform.position = new Vector3(transform.position.x, y, 0); }}Copy the code



As shown above, click the middle play arrow ➡️ button to see the screenshot of the effect:

Key code parsing:

The knowledge in the screenshot below is the core interface MonoBehavior, which is an important class (link at the end)!

This class is used to update the state of the component: we want to program the component to go left, right, up, and down.

Modify block color

This operation small white can not do!

Click on Inspector->Materials -> Element 0 on the right of the screen and select the material of the block.

Final effect:

conclusion

This is just my first experience from installation to development for a developer who has never learned Unity, C# before, and it’s a good start! Also, from this article on, you can save a lot of exploration time by copying the working code directly!

Suggest novice have a look, remember to collect the back of the program to write more review!

And readers please spend a little patience, below is an official LEGO game, efforts will win this crystal, try again next time! There are more cool effects, here you are advised to learn a simple!



(PS: this official version is not compatible with the Unity version of the Student Committee, so this article does not choose to demo this, because it needs to install 14.9G related software, it is estimated that it will not finish in 3 hours)

No matter how good you are at programming, we’re always going to be small potatoes when it comes to new knowledge.

So keep an open mind to learn, so that you can make progress.

The installation and specific operation video will be updated later.

By the way, there is also this you can follow for a long time to read the thunder committee interesting programming story compilation or the thunder Committee NodeJS series

Continuous learning and continuous development, I am Lei Xuewei! Programming is fun. The key is to get the technology right. Creation is not easy, please support, like collection support committee!

Refer to the link

W3c this look, version is not the same, just look for operation inspiration (some operation interface is really different) : www.w3cschool.cn/unity3d_jc/… Unity2017 document: docs.unity3d.com/2017.3/Docu… Docs.unity3d.com/2017.3/Docu…