0x00 Preface
In this article, we have selected some of the more representative issues of Unity's official community Exchange Group and UUG community group over the past few weeks and are here to share with you. Mainly covers the scriptable build Pipeline, Standard Assets, Scripting, Graphics, Vs/vs Code and other fields, which will focus on scriptable build Pipeline and use scriptable Build pipeline pipelining to package Assetbundle related topics.
0x01 scriptable Build Pipeline
Q: i installed the latest 2018.2.1f1, but I did not find scriptable Build Pipeline in Package Manager, what settings do I need?
a: A lot of friends are very concerned about Unity2018 in the scriptable Render Pipeline, you may prefer to be a member of the Appearance association. In fact, in addition to the high degree of concern scriptable Render pipeline,unity2018.2 version also introduced another scriptable Pipeline, that is scriptable Build Pipeline.
But many friends may find that the scriptable build pipeline module cannot be found in the Unity 2018.2 editor, even if scriptable build is not discovered in the package manager Pipeline's package.
In fact, the installation of scriptable Build pipeline is very simple, we just need to modify the project directory under the Packages/manifest.json file can be added to the "dependencies" dependency on SBP.
{
"dependencies": {
"com.unity.scriptablebuildpipeline": "0.2.0-preview"
}
}
In this way, we can install the SBP into our project.
Next, we can call the SBP API to build a assetbundle that everyone is familiar with.
The new build interface is called Contentpipeline.buildassetbundles, which is defined under the UnityEditor.Build.Pipeline namespace. It's a function signature
As you can see, the required parameters are buildparameters, bundlebuildcontent, and Bundlebuildresults, and a returncode is returned for us to see the state of the build, such as success, Error , canceled and so on.
Buildparameters mainly provides some construction parameters, such as the target platform, output path, compression format and so on. Bundlebuildcontent is for SBP to use the asset list that was built as Assetbundle. Bundlebuildresults saved the script compilation and some more detailed results of the assetbundle build.
In response, SBP still retains the traditional build Pipeline, where its name is Legacybuildpipeline.buildassetbundles, and the usage is the same as the previous build script.
So, we can write a simple script that uses both to build a assetbundle and load it at run time.
One interesting result we can find is that Asetbundle built with SBP does not generate mainfest files compared to traditional building methods.
In addition, another big difference is that if we want to use the traditional Assetbundle loading interface to load Assetbundle resources, the Assetbundle built with SBP will pass the full path of the asset when Loadasset. And not just the asset name.
Of course it is slightly more complicated to pass in the full path to load asset, and we also want to be able to specify the asset that need to be packaged directly in the script, then we can use assetbundlebuild to define the data of the AB package. and use the Assetbundlebuild array to create a bundlebuildcontent instance.
The asset indicated in the assetnames field of Assetbundlebuild will be built into the bundle.
In addition, the value of theaddressablenames field can be used instead of the previous full asset path to load the corresponding asset, but there are some bugs in this field when I test on the 0.2.0 preview version. After the development feedback is also quickly repaired, the subsequent version should be able to perform the relevant operations.
Addressable Asset System
What if the resources are not loaded using the traditional resource load API? Have heard of scriptable Build pipeline friends, also must have more or less heard addressable Asset System. The addressable Asset system was actually released in Unity 2018.2, and we used a similar approach to scriptable Build pipeline to activate it.
Again, we're going to modify the Packages/manifest.json file to add addressable Asset system to the dependency.
"dependencies": {
"com.unity.addressables": "0.2.2-preview",
}
This allows us to use the addressable resource system in the project.
However, it is important to note that both SBP and addressable resource systems are still in the preview phase, meaning that there will still be a lot of changes and modifications.
The small example above can be obtained here:
Github.com/chenjd/sbp_assetbundles_demo
The SBP documentation can be viewed by clicking on the link below:
Docs.unity3d.com/packages/com.unity.scriptablebuildpipeline@0.0/api/index.html
The documentation for the addressable resource system can be viewed below:
Docs.unity3d.com/packages/com.unity.addressables@0.2/manual/index.html
0x02 Standard Assets
Q: There is no standard asset option in the Unity2018.2 installation package. What do I need to do if I want to install standard asset?
A: in the Unity2018.2 version, when you install unity through the Unity installer or Unity Hub, you can see that the standard asset option disappears.
This is because the standard asset version is older and can be traced back to the Unity5.0 version. So the new version of Unity will gradually replace the existing standard asset resources.
You can now choose to download the old version of standard Asset from the Asset store, or consider using Unity's new 2D, 3D Game Kit, or other example projects on unity learn.
0x03 Scripting
Q: I now want to implement a dependency injection of a modified field with attribute to create an instance, so I want this attribute to get the type of field that it modifies.
And then in the attribute to build the instance, by the way it modifies the type of the new one to return, assigned to the field it modifies, how to do?
A: all you have to do is customize the attribute and use it to initialize the object according to the type of object it modifies. You can refer to this article: answers.unity.com/questions/896763/custom-attributes.html
( Shenzhen-starsky)
0x04 Graphics
Q1: Hi, hello, everyone! Ask a question, have you used u3d2018.2 GPU instance? I tested the GPU instantiation of the shader, and found that even in the same light map, if the render queue is sorted, the middle is separated by another object, which can result in splitting into multiple batches. However, there is no such phenomenon with static batch processing, if the object is emitted by a high degree of interleaving, GPU instantiation effect is not ideal, do you have any other solution to this situation?
A: It is possible that you can view frame debugger and if there is no merge, there is no reason to merge together. For example, using a GPU instance but a different mesh or submesh will fail.
There is no less use of GPU instance. And 2018.1 added GPU instance support for GI. However, GPU instancing has high hardware requirements, so it is recommended to use static batch for static objects commonly seen in the scene to take into account the low-end devices, for a large number of objects appearing on high-end machines, such as large amounts of grass, trees, such objects can use the GPU Instance, The low-end machine can be removed or not optimized for display.
Q2: ask the big guys. can unity use a spherical harmonic coefficient to produce a high-gloss effect?
A1: The idea is wrong, SH is generally used to provide low-frequency lighting information, not used to do high-gloss.
A2: SH does not reach the high light detail frequency, you write shader hard to do so can, but the high light will change very "flat". (BEIJING-People are ugly will read more books)
A3: not up to. Unity's SH is the third most advanced. Why not bounce the ball? (Shanghai-cgbull)
0x05 Vs/vs Code
Q1: Hello everyone, I use vs code in Unity why not prompt? And there is no error.
The UI cannot be referenced here.
A: You should open a single CS file instead of the entire project. If normal loading, there is no problem.
You can refer to this document: Code.visualstudio.com/docs/other/unity
Q2: No one has ever met Unity5.6.0f3 in the editor after the changes in the code to see still there is no change in the situation?
Inconsistencies between the two sides of the code are shown above.
A: This is usually because you did not tick the auto refresh option in unity preference. This option is in Unity Preference/general.
Check the box.
0x06 PostScript
Well, here are a few of the small issues that we are going to share with you in the group.
Again, we welcome you to join us in this discussion of the official technical Group of dry goods, exchange and share.
Unity Official Community Exchange Group:629212643
-eof-
I'll make a final ad and welcome my book.
Unity 3D Scripting: Developing cross-platform games using the C # language