In this chapter, we will cover:
- Creating a basic material with Standard Shader(Specular setup)
- Adapting a basic material from Specular setup to Metallic
- Applying Normal maps to a Material
- Adding Transparency and Emission maps to a material
In this chapter, we will cover:
In this chapter, we will develop AI algorithms for movement by covering the following recipes:
A delegate is an object that knows how to call a method.
A delegate type defines the method’s return type and its parameter types.
The following defines a delegate type called Transformer:
delegate int Transformer (int x );
Transformer is compatible with any method with an int return type and a single int parameter, such as this:
In this chapter, we cover advanced C# topics that build on concepts explored in Chapters 2 and 3.
You should read the first four sections sequentially; you can read the remaining sections in any order.
Delegates
Generics
C# has two separate mechanisms for writing code that is reusable across different types: inheritance and generics.
Whereas inheritance expresses reusability with a base type.
Generics, when compared to inheritance, can increase type safety and reduce casting and boxing.
C# generics and C++ templates are similar concepts, but they work differently.
Nested Types
A nested type is declared within the scope of another type.
For example:
public class TopLevel
{
Enums
An enum is a special value type that lets you specify a group of named numeric constants.
For example:
public enum BorderSide{ Left, Right, Top, Bottom }
We can use this enum types as follows:
Interfaces
An interface is similar to a class, but it provides a specification rather than an implementation for its members.
An interface is special in the following ways:
In contrast, a class can provide both abstract members and concrete members with implementations.
A struct is similar to a class, with the following key differences:
A struct is a value type, whereas a class is a reference type.
A struct does not support inheritance (other than implicitly deriving from object, or more precisely, System.ValueType).
A struct can have all the members a class can, except the following:
A parameterless constructor
The object Type
object(System.Object) is the ultimate base class for all types.
Any type can be upcast to object.
To illustrate how is useful, consider a general-purpose stack.
A stack is a data structure based on the principle of LIFO - "Last In First Out."
Inheritance
A class can inherit from another class or extend or customize the original class.
Inheriting from a class lets you reuse the functionality in that class instead of building it from scratch.
A class can inherit from only a single class, but can itself be inherited by many classes, thus forming a class hierarchy.
In this example, we start by defining a class called Asset:
A First C# Program
Here is a program that multiplies 12 by 30 and prints the result, 360, to the screen.
The double forward slash indicates that the remainder of a line is a comment.
using System; // importing namespace
class Test // class declaration