First stage: C # Programming in basic 4-unity-0 fundamentals (Unity 2017)

Source: Internet
Author: User

4-C # Programming in Unity-0 Foundation (Unity)

Print can only be exported within the component. = = "Inherits the Monobehaviour script to use."

Debug.Log ();

Debug.logwarning ();

Debug.logerror ();

Definition of a variable
Data and data types
Http://www.cnblogs.com/tonney/archive/2011/03/18/1987577.html

Operator
Https://wenku.baidu.com/view/93c32317a76e58fafab00341.html

19-Enum Type:

Using System;namespace meiju{    enum roletype    {        Mag,        Soldier,        Wizard    }    Class Program    {        static void Main (string[] args)        {            Roletype rt = Roletype.soldier;            Console.WriteLine (RT);            Console.readkey ();}}}    

22-creation, declaration, and construction of classes

Using system.collections;using system.collections.generic;using Unityengine;public class Learncsharp2:monobehaviour {    void Start () {        int hp = +;        A variable declared with a class can be called an object        //enemy enemy1 = new Enemy ();//Construct object        //enemy enemy1 = null;        Print (enemy1);        Enemy enemy1 = new Enemy ();        Print (enemy1.name);        Print (ENEMY1.HP);        Enemy1.name = "Mary";        Print (enemy1.name);        Enemy enemy2 = new Enemy ();        Enemy2.name = "small Two";        Print (Enemy1.name + "-" + enemy2.name);        Enemy1. Move ();        Enemy2. Move ();    }} The field of class Enemy {public    string name;//public can access public int hp through the object    ;    public void Move () {        Debug.Log (name + "Moving");    }    public void Attack () {        Debug.Log ("attacking");}    }

First stage: C # Programming in basic 4-unity-0 fundamentals (Unity 2017)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.