{"id":20749755,"url":"https://github.com/cyberagentgameentertainment/assetregulationmanager","last_synced_at":"2025-04-09T20:09:21.106Z","repository":{"id":36983488,"uuid":"426095401","full_name":"CyberAgentGameEntertainment/AssetRegulationManager","owner":"CyberAgentGameEntertainment","description":"Tool for Unity to create and run tests of Asset Regulations (texture size, number of vertices, etc.), and automate running.","archived":false,"fork":false,"pushed_at":"2022-07-13T02:57:30.000Z","size":4056,"stargazers_count":269,"open_issues_count":0,"forks_count":16,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-09T20:09:13.338Z","etag":null,"topics":["unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyberAgentGameEntertainment.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-09T04:52:49.000Z","updated_at":"2025-03-28T09:50:02.000Z","dependencies_parsed_at":"2022-07-14T04:20:31.577Z","dependency_job_id":null,"html_url":"https://github.com/CyberAgentGameEntertainment/AssetRegulationManager","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentGameEntertainment%2FAssetRegulationManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentGameEntertainment%2FAssetRegulationManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentGameEntertainment%2FAssetRegulationManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyberAgentGameEntertainment%2FAssetRegulationManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyberAgentGameEntertainment","download_url":"https://codeload.github.com/CyberAgentGameEntertainment/AssetRegulationManager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["unity"],"created_at":"2024-11-17T08:24:25.526Z","updated_at":"2025-04-09T20:09:21.076Z","avatar_url":"https://github.com/CyberAgentGameEntertainment.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=500 src=\"Documentation/ARM_LOGO_color_02.png#gh-dark-mode-only\" alt=\"Asset Regulation Manager\"\u003e\n  \u003cimg width=500 src=\"Documentation/ARM_LOGO_bk.png#gh-light-mode-only\" alt=\"Asset Regulation Manager\"\u003e\n\u003c/p\u003e\n\n# ARM: Testing Unity assets automatically\n\n[![license](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.md)\n[![license](https://img.shields.io/badge/PR-welcome-green.svg)](https://github.com/CyberAgentGameEntertainment/AssetRegulationManager/pulls)\n[![license](https://img.shields.io/badge/Unity-2019.4-green.svg)](#Requirements)\n\n**Docs** ([English](README.md), [日本語](README_JA.md))\n\nTool for Unity to create and run tests of Asset Regulations (texture size, number of vertices, etc.), and automate running.\n\n## Table of Contents\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\u003cdetails\u003e\n\u003csummary\u003eDetails\u003c/summary\u003e\n\n- [Concepts \u0026 Features](#concepts--features)\n- [Setup](#setup)\n  - [Requirements](#requirements)\n  - [Install](#install)\n- [Create Asset Regulation Tests](#create-asset-regulation-tests)\n  - [Create an asset to store data](#create-an-asset-to-store-data)\n  - [Create Asset Regulations](#create-asset-regulations)\n  - [Set up targets](#set-up-targets)\n  - [Set up constraints](#set-up-constraints)\n  - [Details on how to use the Asset Regulation Editor](#details-on-how-to-use-the-asset-regulation-editor)\n- [Execute Asset Regulation Tests](#execute-asset-regulation-tests)\n  - [Asset Regulation Viewer](#asset-regulation-viewer)\n  - [Details on how to use the Asset Regulation Viewer](#details-on-how-to-use-the-asset-regulation-viewer)\n- [Test with command line interface (CLI)](#test-with-command-line-interface-cli)\n  - [How to use](#how-to-use)\n  - [Return value](#return-value)\n  - [How to receive results](#how-to-receive-results)\n  - [Command line arguments](#command-line-arguments)\n- [Descriptions of Asset Filters](#descriptions-of-asset-filters)\n- [Descriptions of Asset Constraints](#descriptions-of-asset-constraints)\n- [Scripting](#scripting)\n  - [Edit regulation data assets via scripts](#edit-regulation-data-assets-via-scripts)\n  - [Run tests via scripts](#run-tests-via-scripts)\n  - [Create custom asset filters](#create-custom-asset-filters)\n  - [Create custom asset constraints](#create-custom-asset-constraints)\n- [License](#license)\n\n\u003c/details\u003e\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Concepts \u0026 Features\nIt is important to strictly manage \"**Asset Regulations**\" in Unity game development.\nThe following items are typical examples of Asset Regulations.\n\n* Texture Size\n* Number of Vertices of Mesh\n* File Name\n\nIf these asset regulations are not followed or not clearly defined, the problems like below can occur.\n\n- Asset size increases, resulting in longer download times.\n- Asset size increases, resulting in longer load times.\n- Memory usage increases, resulting in application crashes.\n- Shader processing increases with the number of vertices, resulting in a lower frame rate.\n- Fail to load due to wrong file name.\n\n\n*Asset Regulation Manager* allows you to test such Asset Regulations.\nEveryone (even non-engineers) can easily test through the intuitive interface as shown below.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=800 src=\"Documentation/concept_02.png\" alt=\"Asset Regulation Viewer\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eAsset Regulation Viewer\u003c/font\u003e\n\u003c/p\u003e\n\nAnd the command line interface (CLI) is also available for periodic automated testing.\n\nYou can create the Asset Regulation Tests easily using the GUI tool as shown below.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=800 src=\"Documentation/concept_01.png\" alt=\"Asset Regulation Editor\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eAsset Regulation Editor\u003c/font\u003e\n\u003c/p\u003e\n\n## Setup\n\n### Requirements\nThis library is compatible with the following environment.\n\n* Unity 2019.4 or higher.\n\n### Install\nTo install the software, follow the steps below.\n\n1. Open the Package Manager from Window \u003e Package Manager\n2. \"+\" button \u003e Add package from git URL\n3. Enter the following\n    - https://github.com/CyberAgentGameEntertainment/AssetRegulationManager.git?path=/Assets/AssetRegulationManager\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=500 src=\"Documentation/setup_01.png\" alt=\"Package Manager\"\u003e\n\u003c/p\u003e\n\nOr, open **Packages/manifest.json** and add the following to the **dependencies** block.\n\n```json\n{\n    \"dependencies\": {\n        \"jp.co.cyberagent.assetregulationmanager\": \"https://github.com/CyberAgentGameEntertainment/AssetRegulationManager.git?path=/Assets/AssetRegulationManager\"\n    }\n}\n```\n\nIf you want to set the target version, write as follows.\n\n- [https://github.com/CyberAgentGameEntertainment/AssetRegulationManager.git?path=/Assets/AssetRegulationManager#1.0.0](https://github.com/CyberAgentGameEntertainment/AssetRegulationManager.git?path=/Assets/AssetRegulationManager#1.0.0)\n\nTo update the version, rewrite the version as described above.\nIf you don't want to specify a version, you can also update the version by editing the hash of this library in the **Packages/package-lock.json** file.\n\n```json\n{\n  \"dependencies\": {\n      \"jp.co.cyberagent.assetregulationmanager\": {\n      \"version\": \"https://github.com/CyberAgentGameEntertainment/AssetRegulationManager.git?path=/Assets/AssetRegulationManager\",\n      \"depth\": 0,\n      \"source\": \"git\",\n      \"dependencies\": {},\n      \"hash\": \"...\"\n    }\n  }\n}\n```\n\n\u003e **Note**  \n\u003e If you get a message like No 'git' executable was found. Please install Git on your system and restart Unity, you will need to set up Git on your machine.\n\n\n## Create Asset Regulation Tests\n\n### Create an asset to store data\nTo create Asset Regulation Test, first create a **Regulation Data Asset** from **Assets \u003e Create \u003e Asset Regulation Data**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=500 src=\"Documentation/editor_createasset_01.png\" alt=\"Create Regulation Data Asset\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eCreate Regulation Data Asset\u003c/font\u003e\n\u003c/p\u003e\n\nData regarding Asset Regaultion Tests are stored in this asset.\n\nYou can create multiple assets in your project.\nAnd you can place it anywhere you like, but do not place it in special folders such as StreamingAssets.\n\n### Create Asset Regulations\nNext, double-click on a regulation data asset or press the **Open Editor** button from the Inspector to open the **Asset Regulation Editor**.\nThen press the **+** button in the upper left corner of this window to create a new asset regulation.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=700 src=\"Documentation/editor_createregulation_01.png\" alt=\"Create Asset Regulation\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eCreate Asset Regulation\u003c/font\u003e\n\u003c/p\u003e\n\nOne asset regulation consists of the following two elements.\n\n\u003cu\u003e***Target***\u003c/u\u003e\n- Assets to which this regulation applies.\n- Specify like \"All Texture2D type assets in the Character folder\".\n\n\u003cu\u003e***Constraint***\u003c/u\u003e\n- Constraint that the target assets must adhere to.\n- \"Texture Size must be 1024x1024 or smaller\", \"Texture format must be ASTC4x4\", etc.\n\nThe next step is to set these up.\n\n### Set up targets\nTo set up a target, first click the **Add Asset Group** button on the **Targets** tab in the right panel.\nYou will see a new **Asset Group** named **New Asset Group**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=700 src=\"Documentation/editor_target_01.png\" alt=\"Create Asset Group\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eCreate Asset Group\u003c/font\u003e\n\u003c/p\u003e\n\nYou can specify the target assets by adding **Asset Filters** to this asset group.\nFor example, to target only the assets in the **Characters** folder, press the + button to the right of the asset group name and select **Object Filter** from the menu.\nAnd assign the **Characters** folder to the **Object** property of the added Object Filter.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=700 src=\"Documentation/editor_target_02.png\" alt=\"Create Object Filter\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eCreate Object Filter\u003c/font\u003e\n\u003c/p\u003e\n\nNext, narrow down the targets to Texture2D type assets only.\nPress the + button as before and add **Type Filter**.\nAnd set **Texture2D** to the **Type** property of the added Type Filter.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=700 src=\"Documentation/editor_target_03.png\" alt=\"Create Type Filter\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eCreate Type Filter\u003c/font\u003e\n\u003c/p\u003e\n\nNow, you can target all Texture2D under the Characters folder.\n\nNote that multiple asset groups can be set Up for a single asset regulation.\nIf multiple asset groups are set up, all assets indicated by each asset group will be targets.\nThe figure below shows an example of targeting of all Texture2D files in the Characters folder and all files with the exr extension in the CharacterHDR folder.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=700 src=\"Documentation/editor_target_04.png\" alt=\"Multiple Asset Groups\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eMultiple Asset Groups\u003c/font\u003e\n\u003c/p\u003e\n\n### Set up constraints\nNext, set up constraints.\nFirst, create a constraint regarding max texture size.\nSelect **Add Constraint \u003e Texture \u003e Max Texture Size** from the **Constraints** tab in the right panel.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=700 src=\"Documentation/editor_constraint_01.png\" alt=\"Max Texture Size\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eMax Texture Size\u003c/font\u003e\n\u003c/p\u003e\n\nEnter the maximum size of the texture in the **Max Size** property of the added constraint and you are done.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=700 src=\"Documentation/editor_constraint_02.png\" alt=\"Max Size\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eMax Size\u003c/font\u003e\n\u003c/p\u003e\n\nIn addition, add a constraint regarding texture format.  \nAs before, select **Add Constraint \u003e Texture \u003e Texture Format** to add the constraint.\nThis time, set **Target** to **iOS** and **Format** to **ASTC_6x6**.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=700 src=\"Documentation/editor_constraint_03.png\" alt=\"Texture Format\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eTexture Format\u003c/font\u003e\n\u003c/p\u003e\n\nYou have now set the constraint.\n\n### Details on how to use the Asset Regulation Editor\nThe Asset Regulation Editor also supports the following operations.\n\n1. Select a column to search.\n2. Search regulations.\n3. Select the regulation data asset to edit.\n4. Rename the asset regulation.\n5. Right-click menu\n    - Create a new asset regulation.\n    - Remove the selected asset regulation.\n    - Copy target information as string.\n    - Copy constraint information as string.\n6. Drag to reorder asset regulations.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=800 src=\"Documentation/editor_operation_01.png\" alt=\"Editor Operations\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eEditor Operations\u003c/font\u003e\n\u003c/p\u003e\n\nIn the **Targets** tab, you can do the followings by right-click menu of asset groups.\n\n1. Rename the asset group name.\n2. Remove the asset group.\n3. Reorder the asset group (move up/down).\n4. Copy and paste.\n5. Paste the asset filter.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=400 src=\"Documentation/editor_operation_02.png\" alt=\"Targets Operations\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eTargets Operations\u003c/font\u003e\n\u003c/p\u003e\n\nYou can also do the followings by right-click menu of asset filters.\n\n1. Remove the asset filter.\n2. Reorder the asset filter (move up/down).\n3. Copy and paste.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=400 src=\"Documentation/editor_operation_03.png\" alt=\"Filters Operations\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eFilters Operations\u003c/font\u003e\n\u003c/p\u003e\n\nFrom the right-click menu on the **Constraints** tab, you can do the followings.\n\n1. Remove the asset constraint.\n2. Reorder the asset constraint (move up/down).\n3. Copy and paste.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=400 src=\"Documentation/editor_operation_04.png\" alt=\"Constraints Operations\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eConstraints Operations\u003c/font\u003e\n\u003c/p\u003e\n\n\u003e **Note**  \n\u003e All operations can be undo by pressing **Ctrl (Command) + Z** and redo by pressing **Ctrl (Command) + Y**.\n\n## Execute Asset Regulation Tests\n\n### Asset Regulation Viewer\nYou can open the **Asset Regulation Viewer** from **Window \u003e Asset Regulation Viewer** to test the asset regulations using GUI tool.\n\nFirst, enter the asset name in the search field at the top of the window to search the assets.\nLike the Project view, you can use type search, label search, and glob search (e.g. \"t:Texture\").\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=800 src=\"Documentation/viewer_test_01.png\" alt=\"Search Assets\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eSearch Assets\u003c/font\u003e\n\u003c/p\u003e\n\nYou can show the constraints for the asset by opening the toggle for each asset displayed after the search.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=800 src=\"Documentation/viewer_test_02.png\" alt=\"Show Constraints\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eShow Constraints\u003c/font\u003e\n\u003c/p\u003e\n\nTo test Asset Regulation, double-click on the target row.\n\nAlso you can test the all displayed Asset Regulations by pressing the **Run All** button.  \nIf you want to test only asset regulations you selected, use the **Run Selected** button.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=800 src=\"Documentation/viewer_test_03.png\" alt=\"Run Tests\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eRun Tests\u003c/font\u003e\n\u003c/p\u003e\n\n### Details on how to use the Asset Regulation Viewer\nThe Asset Regulation Viewer also supports the following operations.\n\n1. Reload.\n2. Open the menu.\n3. Show/Hide assets with no asset regulations.\n4. Export test result.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=800 src=\"Documentation/viewer_operation_01.png\" alt=\"Viewer Operations\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eViewer Operations\u003c/font\u003e\n\u003c/p\u003e\n\n## Test with command line interface (CLI)\n\n### How to use\nYou can test Asset Regulations with the following method.\n\n`AssetRegulationManager.Editor.Core.Tool.Test.AssetRegulationTestCLI.AssetRegulationTestCLI.ExecuteTests`\n\nThe following is an example of command line on Mac.\n\n```bash\n/Applications/Unity/Hub/Editor/2019.4.33f1/Unity.app/Contents/MacOS/Unity -projectPath [Your Project Path Here] -executeMethod AssetRegulationManager.Editor.Core.Tool.Test.AssetRegulationTestCLI.AssetRegulationTestCLI.ExecuteTests\n```\n\n### Return value\nThe return value of the command line is as follows.\n\n| Return Value | Description |\n| --- | --- |\n| 0 | All tests succeeded. |\n| 1 | Failed test exists. But, with the -failWhenWarning option, this value is returned even when the warning is contained. |\n| 2 | Execution failed. |\n\n### How to receive results\nThe test results are saved to a file.\nYou can specify the file path using the command line argument `-resultFilePath`.\n\nThe results will be written out like following.\n\n```\nAssets/Development/DevelopmentAssets/tex_dev_red_128.png\n[Success] Texture Format: RGBA32 (iPhone) | Actual Value: RGBA32\n[Success] Max Texture Size: 200 x 200 | Actual Value: 128 x 128\n\nAssets/Development/DevelopmentAssets/tex_dev_red_256.png\n[Failed] Texture Format: RGBA32 (iPhone) | Actual Value: ASTC_6x6\n[Failed] Max Texture Size: 200 x 200 | Actual Value: 256 x 256\n```\n\nNote that you can output the results as json like follows by specifing `Json` as the command line argument `-resultFormat`.\n\n```json\n{\"results\":[{\"assetPath\":\"Assets/Development/DevelopmentAssets/tex_dev_red_128.png\",\"entries\":[{\"status\":\"Success\",\"description\":\"Texture Format: RGBA32 (iPhone)\",\"message\":\"Actual Value: ASTC_6x6\"},{\"status\":\"Success\",\"description\":\"Max Texture Size: 200 x 200\",\"message\":\"Actual Value: 256 x 256\"}]},{\"assetPath\":\"Assets/Development/DevelopmentAssets/tex_dev_red_256.png\",\"entries\":[{\"status\":\"Failed\",\"description\":\"Texture Format: RGBA32 (iPhone)\",\"message\":\"Actual Value: ASTC_6x6\"},{\"status\":\"Failed\",\"description\":\"Max Texture Size: 200 x 200\",\"message\":\"Actual Value: 256 x 256\"}]}]}\n```\n\n### Command line arguments\nThe command line arguments are described below.\n\n| Name | Description |\n| --- | --- |\n| -resultFilePath \\\u003cfilePath\u003e | Specifies the output file path for test results. Default value is AssetRegulationManager/test_result.txt (or .json). |\n| -resultFormat \\\u003cformatName\u003e | Specifies the output format of the results.\u003cbr\u003e\u003cbr\u003e* List (default)\u003cbr\u003e* Json |\n| -resultFilter \\\u003cfilterName\u003e | Filters test results by status.\u003cbr\u003e\u003cbr\u003e* All: Output all results. (default)\u003cbr\u003e* Success: Output only successful results.\u003cbr\u003e* Warning: Output only results with warnings.\u003cbr\u003e* Failed: Output only failed results.\u003cbr\u003e\u003cbr\u003eYou can specify multiple options by enclosing them with \"\" and separating with semicolons. For example, to output warnings and failures, specify as following.\u003cbr\u003e\u003cbr\u003e-resultFilter \"Warning;Failed\" |\n| -assetFilter \\\u003cassetPath\u003e | Filters test target assets. Specify the asset paths. You can specify multiple paths by enclosing them with \"\" and separating with semicolons. And you can also use regular expressions.\u003cbr\u003e\u003cbr\u003eFor example, to target the files that have \"mesh_\" or \"tex_\" in their path, specify as following.\u003cbr\u003e\u003cbr\u003e-assetFilter \"mesh_;tex_\" |\n| -regulationFilter \\\u003cregulationName\u003e | Filters asset regulations for testing. Specify the asset regulation names. You can specify multiple regulations by enclosing them with \"\" and separating with semicolons. And you can also use regular expressions.\u003cbr\u003e\u003cbr\u003eFor example, to target the regulations named \"Character Prefabs\" and \"Character Textures\", specify as following.\u003cbr\u003e\u003cbr\u003e-regulationFilter \"^Character Prefabs$;^Character Textures$\" |\n\n## Descriptions of Asset Filters\n\n| Name | Overview and Property Description |\n| --- | --- |\n| Object Filter | Filters by specifying the asset directly.\u003cbr\u003eUse case: Target only assets under the Characters folder.\u003cbr\u003e\u003cbr\u003e**Folder Targeting Mode**\u003cbr\u003eSpecify how folders are handled.\u003cbr\u003e* Included Assets (Exclude Folders): Targets only assets in the folders.\u003cbr\u003e* Self: Targets only the folders themselves.\u003cbr\u003e* Both: Targets the folders and the included assets.\u003cbr\u003e\u003cbr\u003e**Object**\u003cbr\u003eTarget asset. If you specify a folder, target all assets in the folder. Multiple items can be specified by using the right toggle. |\n| Type Filter | Filters by asset type.\u003cbr\u003eUse case: Targets only Texture2d type assets.\u003cbr\u003e\u003cbr\u003e**Match With Derived Type**\u003cbr\u003eIf checked, derived types are also covered.\u003cbr\u003e\u003cbr\u003e**Type**\u003cbr\u003eTarget type. Multiple items can be specified by using the right toggle. |\n| Asset Path Filter | Filters by asset path.\u003cbr\u003eUse case 1: Target assets contained in the folder named \"Assets/Sample[Any 3 characters]/\".\u003cbr\u003eUse case 2: Exclude assets that contain \"Dummy\" in the file name.\u003cbr\u003e\u003cbr\u003e**Match With Folders**\u003cbr\u003eTargets the folders or not.\u003cbr\u003e\u003cbr\u003e**Asset Path (Regex)**\u003cbr\u003eTarget asset path. Assets whose paths partially match these will be targeted. You can also use regular expressions. Multiple items can be specified by using the right toggle.\u003cbr\u003e\u003cbr\u003e**Condition**\u003cbr\u003eSpecify how to handle multiple Asset Paths.\u003cbr\u003e* Contains Matched: Target if any asset path matches.\u003cbr\u003e* Match All: Target if all asset paths match.\u003cbr\u003e* Contains Unmatched: Target if any one asset path does not match.\u003cbr\u003e* Not Match All: Target if all asset paths do not match. |\n| Extension Filter | Filters by extension.\u003cbr\u003eUse case: Target assets that have png or jpg extension.\u003cbr\u003e\u003cbr\u003e**Extension**\u003cbr\u003eTarget extension. Multiple items can be specified by using the right toggle. |\n| Dependent Object Filter | Filters the assets that are referenced by the specified asset.\u003cbr\u003eUse case: Targets the textures that are referenced by the prefab.\u003cbr\u003e\u003cbr\u003e**Only Direct Dependencies**\u003cbr\u003eTargets the assets that are referenced directly.\u003cbr\u003e\u003cbr\u003e**Object**\u003cbr\u003eReferer Assets. |\n\n## Descriptions of Asset Constraints\n| Name | Overview and Property Description |\n| --- | --- |\n| File/Asset Path | Constrains asset paths.\u003cbr\u003e\u003cbr\u003e**Asset Path (Regex)**\u003cbr\u003eTarget asset path. You can also use regular expressions. Multiple items can be specified by using the right toggle.\u003cbr\u003e\u003cbr\u003e**Condition**\u003cbr\u003eYou can specify how to handle multiple Asset Paths.\u003cbr\u003e* Or: Target if any asset path matches.\u003cbr\u003e* And: Target if all asset paths match. |\n| File/File Size | Constrains file size.\u003cbr\u003e\u003cbr\u003e**Max Size**\u003cbr\u003eMaximum asset size.\u003cbr\u003e\u003cbr\u003e**Unit**\u003cbr\u003eSize unit.\u003cbr\u003e* B: Byte\u003cbr\u003e* KB: Kilobyte (Kibibyte)\u003cbr\u003e* MB: Megabyte (Mebibyte) |\n| File/Folder | Constrains belonging folder.\u003cbr\u003e\u003cbr\u003e**Folder**\u003cbr\u003eTarget folder. Multiple items can be specified by using the right toggle.\u003cbr\u003e\u003cbr\u003e**Check Mode**\u003cbr\u003eYou can specify how to handle multiple folders.\u003cbr\u003e* Contains: Check that it is included in the folder.\u003cbr\u003e* Not Contains: Check that it is NOT included in the folder.\u003cbr\u003e\u003cbr\u003e**Top Folder Only**\u003cbr\u003eIf checked, targets only directly under the folder. |\n| File/Asset Type | Constrains asset types.\u003cbr\u003e\u003cbr\u003e**Match With Derived Types**\u003cbr\u003eIf checked, targets the derived types.\u003cbr\u003e\u003cbr\u003e**Type**\u003cbr\u003etype. |\n| Texture/Max Texture Size | Constrains texture size.\u003cbr\u003e\u003cbr\u003e**Count Mode**\u003cbr\u003eSpecify the size calculation method.\u003cbr\u003e* Width And Height: Specify the width and height of the texture.\u003cbr\u003e* Texel Count: Specify the number of texels in the texture.\u003cbr\u003e\u003cbr\u003e**Max Size / Max Texel Count**\u003cbr\u003eTexture size. |\n| Texture/Texture Format | Constrains texture format.\u003cbr\u003e\u003cbr\u003e**Target**\u003cbr\u003eSpecify target platform. Multiple items can be specified by using the right toggle.\u003cbr\u003e\u003cbr\u003e**Format**\u003cbr\u003eSpecify texture format. Multiple items can be specified by using the right toggle. |\n| Texture/Max Texel Count in Asset | Constrains the total number of texels referenced by the asset.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMax texel count. |\n| Texture/Max Texel Count in GameObject | Constrains the total number of texels referenced by the GameObject's Renderer.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMax texel count.\u003cbr\u003e\u003cbr\u003e**Exclude Children**\u003cbr\u003eIf checked, child GameObjects are excluded from the check.\u003cbr\u003e\u003cbr\u003e**Exclude Inactive**\u003cbr\u003eIf checked, inactive GameObjects are excluded from the check.\u003cbr\u003e\u003cbr\u003e**Allow Duplicate Count**\u003cbr\u003eIf checked, counts twice if another renderer is referencing the same texture. |\n| Texture/Max Texel Count in Scene | Constrains the total number of texture texels referenced by the Renderer of GameObjects in the scene.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMaximum texel count.\u003cbr\u003e\u003cbr\u003e**Exclude Inactive**\u003cbr\u003eIf checked, inactive GameObjects are excluded from the check.\u003cbr\u003e\u003cbr\u003e**Allow Duplicate Count**\u003cbr\u003eIf checked, counts twice if another renderer is referencing the same texture. |\n| Texture/Max Texel Count in Folder | Constrains the total number of texels of textures in the folder.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMax texel count.\u003cbr\u003e\u003cbr\u003e**Top Folders Only**\u003cbr\u003eIf checked, targets only the textures located directly under the folder. |\n| Mesh/Max Vertex Count | Constrains the total number of mesh vertices.\u003cbr\u003eIt can be used as a constraint for Mesh and GameObjects (Prefab, FBX, etc.).\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMaximum vertex count.\u003cbr\u003e\u003cbr\u003e**Exclude Children**\u003cbr\u003eIf checked, child GameObjects are excluded from the check.\u003cbr\u003eNote: Only available if the target asset is GameObject.\u003cbr\u003e\u003cbr\u003e**Exclude Inactive**\u003cbr\u003eIf checked, inactive GameObjects are excluded from the check.\u003cbr\u003eNote: Only available if the target asset is GameObject.\u003cbr\u003e\u003cbr\u003e**Allow Duplicate Count**\u003cbr\u003eIf checked, counts twice if another renderer is referencing the same texture.\u003cbr\u003eNote: Only available if the target asset is GameObject. |\n| Mesh/Max Vertex Count in Scene | Constrains the maximum total number of vertices for all meshes in the scene.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMaximum vetex count.\u003cbr\u003e\u003cbr\u003e**Exclude Inactive**\u003cbr\u003eIf checked, inactive GameObjects are excluded from the check.\u003cbr\u003e\u003cbr\u003e**Allow Duplicate Count**\u003cbr\u003eIf checked, counts twice if another renderer is referencing the same texture. |\n| GameObject/Max GameObject Count in GameObject | Constrains GameObject count in a Prefab.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMaximum GameObject count.\u003cbr\u003e\u003cbr\u003e**Exclude Inactive**\u003cbr\u003eIf checked, inactive GameObjects are excluded from the check. |\n| GameObject/Max GameObject Count in Scene | Constrains GameObject count in a Scene.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMaximum GameObject count.\u003cbr\u003e\u003cbr\u003e**Exclude Inactive**\u003cbr\u003eIf checked, inactive GameObjects are excluded from the check. |\n| Particle System/Max ParticleSystem Count in GameObject | Constrains particle system count in a prefab.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMaximum particle system count.\u003cbr\u003e\u003cbr\u003e**Exclude Inactive**\u003cbr\u003eIf checked, inactive GameObjects are excluded from the check. |\n| Particle System/Max ParticleSystem Count in Scene | Constrains particle system count in a scene.\u003cbr\u003e\u003cbr\u003e**Max Count**\u003cbr\u003eMaximum particle system count.\u003cbr\u003e\u003cbr\u003e**Exclude Inactive**\u003cbr\u003eIf checked, inactive GameObjects are excluded from the check. |\n| Material/Shader Keyword | Constrains the shader keywords enabled in a material.\u003cbr\u003e\u003cbr\u003e**Check Condition**\u003cbr\u003eHow to handle specified keywords.\u003cbr\u003e* Enabled All: Check that all keywords are enabled.\u003cbr\u003e* Enabled Any: Check that any of the keywords are enabled.\u003cbr\u003e* Disabled All: Check that all keywords are disabled.\u003cbr\u003e* Disabled Any: Check that any of the keywords are disabled.\u003cbr\u003e\u003cbr\u003e**Shader Keyword**\u003cbr\u003eShader keyword. |\n\n## Scripting\n\n### Edit regulation data assets via scripts\nTo edit regulation data assets via script, do like following.\n\n```cs\nusing AssetRegulationManager.Editor.Core.Data;\nusing AssetRegulationManager.Editor.Core.Model.AssetRegulations;\nusing AssetRegulationManager.Editor.Core.Model.AssetRegulations.AssetConstraintImpl;\nusing AssetRegulationManager.Editor.Core.Model.AssetRegulations.AssetFilterImpl;\nusing UnityEditor;\nusing UnityEngine;\n\npublic static class AssetRegulationManagerScripting\n{\n    [MenuItem(\"Asset Regulation Manager/Samples/Create Data Asset\")]\n    private static void CreateDataAsset()\n    {\n        // Create data asset.\n        var store = ScriptableObject.CreateInstance\u003cAssetRegulationSetStore\u003e();\n        AssetDatabase.CreateAsset(store, \"Assets/sample.asset\");\n\n        // Create and add a regulation.\n        var regulation = new AssetRegulation();\n        store.Set.Add(regulation);\n\n        // Create targets.\n        var assetGroup = regulation.AddAssetGroup();\n        var extensionFilter = assetGroup.AddFilter\u003cExtensionBasedAssetFilter\u003e();\n        extensionFilter.Extension.IsListMode = true;\n        extensionFilter.Extension.AddValue(\"png\");\n        extensionFilter.Extension.AddValue(\"jpg\");\n\n        // Create constraints.\n        var fileSizeConstraint = regulation.AddConstraint\u003cFileSizeConstraint\u003e();\n        fileSizeConstraint.Unit = FileSizeConstraint.SizeUnit.KB;\n        fileSizeConstraint.MaxSize = 50;\n\n        EditorUtility.SetDirty(store);\n        AssetDatabase.SaveAssets();\n    }\n}\n```\n\n### Run tests via scripts\nTo run regulation tests via script, do like following.\n\n```cs\nusing System.Collections.Generic;\nusing AssetRegulationManager.Editor.Core.Data;\nusing AssetRegulationManager.Editor.Core.Model;\nusing AssetRegulationManager.Editor.Core.Model.Adapters;\nusing AssetRegulationManager.Editor.Core.Model.AssetRegulationTests;\nusing UnityEditor;\n\npublic static class AssetRegulationManagerScripting\n{\n    [MenuItem(\"Asset Regulation Manager/Samples/Execute Tests\")]\n    private static void ExecuteTests()\n    {\n        var repository = new AssetRegulationRepository();\n        var testStore = new AssetRegulationTestStore();\n        var assetDatabaseAdapter = new AssetDatabaseAdapter();\n        var testGenerateService =\n            new AssetRegulationTestGenerateService(repository, testStore, assetDatabaseAdapter);\n        var testExecuteService = new AssetRegulationTestExecuteService(testStore);\n\n        // Create tests.\n        // Enter a filter as you would when searching in the project view.\n        testGenerateService.Run(\"t:Object\");\n\n        // Filter tests.\n        testStore.FilterTests(AssetRegulationTestStoreFilter.ExcludeEmptyTests);\n\n        // Execute tests.\n        testExecuteService.RunAll();\n\n        // Export test results (optional).\n        var testResultExportService = new AssetRegulationTestResultExportService(testStore);\n        var exportTargetStatuses = new List\u003cAssetRegulationTestStatus\u003e\n        {\n            AssetRegulationTestStatus.Warning,\n            AssetRegulationTestStatus.Failed\n        };\n        testResultExportService.Run(\"filepath.txt\", exportTargetStatuses);\n\n        // If you want to analyze the test results yourself, do as follows.\n        foreach (var test in testStore.FilteredTests)\n        {\n            var targetAssetPath = test.AssetPath;\n            // This will be Success if the status of the all entries is Success.\n            var testStatus = test.LatestStatus.Value;\n\n            foreach (var entry in test.Entries.Values)\n            {\n                // e.g. Success\n                var testEntryStatus = entry.Status.Value;\n                // e.g. Max Texture Size: 200 x 200\n                var testEntryDescription = entry.Description;\n                // e.g. Actual Value: 128 x 128\n                var message = entry.Message.Value;\n            }\n        }\n    }\n}\n```\n\n### Create custom asset filters\nYou can create your own asset filter by creating a class derived from `AssetFilterBase` in the Editor folder.\n\n```cs\nusing System;\nusing AssetRegulationManager.Editor.Core.Model.AssetRegulations;\nusing AssetRegulationManager.Editor.Core.Model.AssetRegulations.AssetFilterImpl;\n\n[Serializable]\n[AssetFilter(\"Custom Filter\", \"Custom Filter\")] // Required for GUI.\npublic class CustomAssetFilter : AssetFilterBase\n{\n    public string AssetPathToMatch { get; set; }\n\n    /// This will be called before and less often than IsMatch.\n    /// And will be executed in the main thread, in contrast to IsMatch.\n    /// So you should write heavy processes or processes that use Unity's API here.\n    public override void SetupForMatching()\n    {\n    }\n\n    // Return true if the asset passes this filter.\n    // This may be executed outside the main thread.\n    public override bool IsMatch(string assetPath, Type assetType)\n    {\n        return AssetPathToMatch == assetPath;\n    }\n\n    // A description of this asset filter.\n    public override string GetDescription()\n    {\n        return string.IsNullOrEmpty(AssetPathToMatch) ? string.Empty : $\"Asset Path: {AssetPathToMatch}\";\n    }\n}\n```\n\nA class derived from `GUIDrawer` is also required for GUI.\n\n```cs\nusing AssetRegulationManager.Editor.Foundation.CustomDrawers;\nusing UnityEditor;\n\n[CustomGUIDrawer(typeof(CustomAssetFilter))]\npublic sealed class CustomAssetFilterDrawer : GUIDrawer\u003cCustomAssetFilter\u003e\n{\n    public override void Setup(object target)\n    {\n        base.Setup(target);\n\n        // If you want to setup this drawer, write here.\n    }\n\n    protected override void GUILayout(CustomAssetFilter target)\n    {\n        target.AssetPathToMatch = EditorGUILayout.TextField(\"Asset Path\", target.AssetPathToMatch);\n    }\n}\n```\n\nNow you have created the custom asset filter.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=400 src=\"Documentation/scripting_customfilter_01.png\" alt=\"Custom Filter\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eCustom Filter\u003c/font\u003e\n\u003c/p\u003e\n\n### Create custom asset constraints\nYou can create your own asset constraint by creating a class derived from `AssetConstraint` in the Editor folder.\n\n```cs\nusing System;\nusing System.IO;\nusing AssetRegulationManager.Editor.Core.Model.AssetRegulations;\nusing UnityEditor;\nusing UnityEngine;\nusing UnityEngine.Assertions;\nusing Object = UnityEngine.Object;\n\n[Serializable]\n[AssetConstraint(\"Custom/Custom Constraint\", \"Custom Constraint\")] // Required for GUI.\npublic sealed class CustomAssetConstraint : AssetConstraint\u003cObject\u003e\n{\n    [SerializeField] private string _assetName;\n\n    private string _latestValue;\n\n    public string AssetName\n    {\n        get =\u003e _assetName;\n        set =\u003e _assetName = value;\n    }\n\n    // Get a description of this constraint.\n    public override string GetDescription()\n    {\n        return $\"Asset Name: {_assetName}\";\n    }\n\n    // Returns the most recently used value for the test as a string.\n    public override string GetLatestValueAsText()\n    {\n        return string.IsNullOrEmpty(_latestValue) ? \"None\" : _latestValue;\n    }\n\n    // Returns true if the asset is within constraints.\n    protected override bool CheckInternal(Object asset)\n    {\n        Assert.IsNotNull(asset);\n\n        var assetPath = AssetDatabase.GetAssetPath(asset);\n        var assetName = Path.GetFileNameWithoutExtension(assetPath);\n        _latestValue = assetName;\n\n        return _assetName == assetName;\n    }\n}\n```\n\nA class derived from `GUIDrawer` is also required for GUI.\n\n```cs\nusing AssetRegulationManager.Editor.Foundation.CustomDrawers;\nusing UnityEditor;\n\n[CustomGUIDrawer(typeof(CustomAssetConstraint))]\npublic sealed class CustomAssetConstraintDrawer : GUIDrawer\u003cCustomAssetConstraint\u003e\n{\n    public override void Setup(object target)\n    {\n        base.Setup(target);\n\n        // If you want to setup this drawer, write here.\n    }\n\n    protected override void GUILayout(CustomAssetConstraint target)\n    {\n        target.AssetName = EditorGUILayout.TextField(\"Asset Name\", target.AssetName);\n    }\n}\n```\n\nNow you have created the custom asset constraint.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=400 src=\"Documentation/scripting_customconstraint_01.png\" alt=\"Custom Constraint\"\u003e\u003cbr\u003e\n  \u003cfont color=\"grey\"\u003eCustom Constraint\u003c/font\u003e\n\u003c/p\u003e\n\n## License\nThis software is released under the MIT license. You are free to use it within the scope of the license, but the following copyright and license notices are required.\n\n* [LICENSE.md](LICENSE.md)\n\nIn addition, the table of contents for this document has been created using the following software.\n\n* [toc-generator](https://github.com/technote-space/toc-generator)\n\nSee [Third Party Notices.md](Third%20Party%20Notices.md) for more information about the license of toc-generator.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberagentgameentertainment%2Fassetregulationmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyberagentgameentertainment%2Fassetregulationmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyberagentgameentertainment%2Fassetregulationmanager/lists"}