- Unity 2018 Shaders and Effects Cookbook
- John P. Doran Alan Zucconi
- 345字
- 2021-06-18 19:04:14
How it works...
Every Unity shader has a built-in structure that it is looking for in its code. The Properties block is one of those functions that are expected by Unity. The reason behind this is to give you, the shader programmer, a means of quickly creating GUI elements that tie directly into your shader code. These properties (variables) that you declare in the Properties block can then be used in your shader code to change values, colors, and textures. The syntax to define a property is as follows:

Let's take a look at what is going on under the hood here. When you first start writing a new property, you will need to give it a Variable Name. The Variable Name is going to be the name that your shader code is going to use in order to get the value from the GUI element. This saves us a lot of time because we don't have to set up this system ourselves. The next elements of a property are the Inspector GUI Name and Type of the property, which is contained within parentheses. The Inspector GUI Name is the name that is going to appear in the material's Inspector tab when the user is interacting with and tweaking the shader. The Type is the type of data that this property is going to control. There are many types that we can define for properties inside of Unity shaders. The following table describes the types of variables that we can have in our shaders:

Finally, there is the Default Value. This simply sets the value of this property to the value that you place in the code. So, in the previous example diagram, the default value for the property named _AmbientColor, which is of the Color type, is set to a value of 1, 1, 1, 1. As this is a Color property expecting a color that is RGBA or float4 or r, g, b, a = x, y, z, w, this Color property, when first created, is set to white.
- JavaScript百煉成仙
- 神經(jīng)網(wǎng)絡(luò)編程實戰(zhàn):Java語言實現(xiàn)(原書第2版)
- Python王者歸來
- Internet of Things with Intel Galileo
- C語言程序設(shè)計實踐教程
- Android 應(yīng)用案例開發(fā)大全(第3版)
- 組態(tài)軟件技術(shù)與應(yīng)用
- Learning FuelPHP for Effective PHP Development
- 單片機(jī)C語言程序設(shè)計實訓(xùn)100例
- AIRIOT物聯(lián)網(wǎng)平臺開發(fā)框架應(yīng)用與實戰(zhàn)
- Tableau 10 Bootcamp
- C語言開發(fā)基礎(chǔ)教程(Dev-C++)(第2版)
- C語言程序設(shè)計實訓(xùn)教程與水平考試指導(dǎo)
- Advanced UFT 12 for Test Engineers Cookbook
- 會當(dāng)凌絕頂:Java開發(fā)修行實錄