6: 2015-06-25 (木) 00:03:38 iseki  |
現: 2015-07-13 (月) 14:01:38 iseki  |
| | - http://ft-lab.ne.jp/cgi-bin-unity/wiki.cgi?page=unity_first | | - http://ft-lab.ne.jp/cgi-bin-unity/wiki.cgi?page=unity_first |
| | #br | | #br |
| - | using UnityEngine; | + | *** Scripts [#t1147094] |
| - | using UnityEditor; | + | **** Input.GetKeyDown(), Input.GetKeyUp() の取りこぼし [#t95d08ba] |
| - | using System.IO; | + | - GetKeyDown(), GetKeyUp() 系は1フレームのみの通知なので,FixedUpdate() ではなく Update() に記述する. |
| - | | + | #br |
| - | public sealed class SelectColladaShader : AssetPostprocessor | + | |
| - | { | + | |
| - | Material OnAssignMaterialModel(Material material,Renderer renderer) | + | |
| - | { | + | |
| - | string currentDir = Path.GetDirectoryName (assetPath); | + | |
| - | if (!AssetDatabase.IsValidFolder (currentDir + "/Materials")) { | + | |
| - | AssetDatabase.CreateFolder (currentDir, "Materials"); | + | |
| - | } | + | |
| - | | + | |
| - | if (material.mainTexture == null) { | + | |
| - | return null; | + | |
| - | } | + | |
| - | string textureName = material.mainTexture.name; | + | |
| - | string materialPath = string.Format("{0}/Materials/{1}.mat", currentDir, textureName); | + | |
| - | | + | |
| - | Material mt = AssetDatabase.LoadAssetAtPath<Material>(materialPath); | + | |
| - | | + | |
| - | if (mt==null) { | + | |
| - | material.shader = Shader.Find("Legacy Shaders/Transparent/Diffuse"); | + | |
| - | AssetDatabase.CreateAsset(material, materialPath); | + | |
| - | // | + | |
| - | mt = material; | + | |
| - | } | + | |
| - | | + | |
| - | return mt; | + | |
| - | } | + | |
| - | } | + | |
|
|
| |