Assetpostprocessor



How to work with Excel

Assetpostprocessor

Unity Assetpostprocessor

This post shows and helps you how to set up and use Unity-QuickSheet with excel.

Excel versions 97/2000/XP/2003 are suppported for '.xls' (due to that NPOI, an open source project used to read excel spreadsheet for Unity-QuickSheet does not support Excel versions 5.0/95 for '.xls') It's doesn't matter with '.xlsx'

This is a great time to learn about the AssetPostProcessor!Specifically, AssetPostProcessor.OnPreprocessTexture will allow you to automatically handle the import settings of textures in your Unity project. It will modify their meta files as they're imported and Right-click Reimport will force them to run (you can use this on a whole directory; even the whole Assets directory). Note: when reimporting 'MyTexture' it is changed by a custom AssetPostprocessor but the applied changes are not seen in the SpriteAtlas as mentioned. AssetPostprocessor.OnPostprocessPrefab 関数は、最後のプレハブが作成される前とそれがディスクに書き込まれる前に呼び出されます。したがって、生成されたゲームオブジェクトとコンポーネントを完全に制御できます。. The asset postprocessor point of existence is to be actually executed each time any asset in the project structure changes. In order to prevent a post-processor from taking too much time while it executes, you need to change your logic in a way that rejects unneeded assets as quickly as possible.

Before starting, check your spreadsheet page again. It should start without an empty row which means the first row should not be an empty one.

Step 1) Create Excel Setting File

First you need thing to do is creating an excel setting file. Simply right click on the Project view and select 'Create > Spreadsheet Tools > Excel'. It creates a new file which shows various setting to create script files and get data from the specified excel file.

Select Excel menu item then it creates setting file. It may be shown like the following:

Let's start to do settinig.

File Setting

File setting is setting for what excel file and its sheet page to import.

First you should specify what excel file to import.

  1. Select an excel file to import with File Open Dialog.

An excel file can have one or more sheet pages so you need to decide what sheet you select and retrieve data from.

  1. Select a sheet page you want to import.

  2. Press Import button imports the specified excel file and shows all column headers.

Type Setting

Importing the specified sheet page shows all column headers of the page. That are neccessary to let you set the type of the each cells.

Set the proper type of the cells.

Currently the following types are supoorted:

  • string
  • int
  • float
  • double
  • enum
  • bool

Path Setting

Path setting are concerned with specifying paths where the generated script files are put.

Note: All paths should be relative without 'Assets/'.`

  1. Template indicates a path where template files which are neccessary to generate script files. In most case you don't need to change it.
  2. Runtime indicates a path where generated script files which are used on runtime will be put.
  3. Editor inidicates a path where generated script files which are used on editor mode will be put.

Step 2) Generating Script Files

If you've done all necessary setting, it's time to generate some script files which are needed for reading data in from the sheet page of the excel file and to store that within ScriptableObject which is being as an asset file in the Project View.

Press Generate button. Phones for mac users.

After generating some script files, Unity Editor starts to compile those. Wait till Unity ends doing compile then check the specified Editor and Runtime paths all necessary script files are correctly generated.

In Editor folder should have contain two files:

  • your-sheetpage-nameAssetPostProcessor.cs
  • your-sheetpage-nameEditor.cs

In Runtime foller should have contain tow files:

  • your-sheetpag-name.cs
  • your-sheetpage-nameData.cs

See the your-sheetpage-nameData.cs file. The class members of the file represent each cells of the sheet page.

Step 3) Importing Spreadsheet Data

Creating asset file and importing data from the spreadsheet file into that created asset file is done just by simply doing reimport any xls or xlsx file within Project view.

Reimporting xls or xlsx file will automatically create an asset file which has same file name as the sheet page name(not excel file name) and automatically import data from the sheet page of the excel file into the created asset file.

It's done. Hope you enjoy that!

07 Nov 2017

Games aren’t always made by a one-man-team but involve several developers, who are people akin to making mistakes,that in turn increase dev cost time. Importing assets is no joke, with the default settings and different rules for different parts of your project, let’s start with this premise and ask ourselves: “can we write tools to prevent common, costly mistakes ?”

Games aren’t always made by a one-man-team but involve several developers, who are people akin to making mistakes,that in turn increase dev cost time. Importing assets is no joke, with the default settings and different rules for different parts of your project, let’s start with this premise and ask ourselves: “can we write tools to prevent common, costly mistakes ?”

the answer is yes and let’s discover one cool Unity3D Class.

Onpostprocessallassets

AssetPostprocessor:

the AssetPostProcessor class receive callbacks on importing something. it implements OnPreProcess* and OnPostProcess* methods and apply your rules to the assetImporter instance.therefore we can write rules that prevent some common mistakes, let’s take textures for instance, we can ensure:

  • setting the texture type (deault, sprite, etc.)
  • making sure Read/Write is disabled.
  • disabling mipmaps for anything that is 2D or UI (it is enabled by default).
  • forcing a max texture size

Now with the above script, is it easier for the team to comply to naming conventions rather than cherrypick settings for different parts of a project.

Facetime for mac download free. we can also implement the same OnPreprocessModel() method for meshes to audit some common errors:

• Make sure Read/Write is disabled• Disabling rig on non-character models (it fixes the auto added Animator component)• Copy avatars for characters with shared rigs• Enable mesh compression

and of course, also applies for Audio.