#if UNITY_EDITOR using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; using UnityEngine.Experimental.Rendering; public class OrificeSetup : ScriptableWizard { public GameObject orifice; private string errorInfo=""; private int[] shapes; private Material orificeMaterial; [MenuItem("Tools/Raliv/Orifice Setup")] static void Setup() { ScriptableWizard.DisplayWizard("Orifice Setup"); } private List blendshapeNameList(Mesh m) { List nameList = new List(); nameList.Add("None"); for (int i=0; i(); Mesh mesh = meshRenderer.sharedMesh; if (mesh.tangents.Length0) BlitShape(texture, mesh, shapes[0]-1, 0); if (shapes[1]>0) BlitShape(texture, mesh, shapes[1]-1, 1); if (shapes[2]>0) BlitShape(texture, mesh, shapes[2]-1, 2); if (shapes[3]>0) BlitShape(texture, mesh, shapes[3]-1, 3); texture.Apply(); AssetDatabase.CreateAsset(texture, "Assets/RalivDynamicPenetrationSystem/MyData/"+orifice.name+".asset"); AssetDatabase.SaveAssets(); if (orifice.GetComponent()!=null) { orificeMaterial.SetTexture("_OrificeData",(Texture2D)AssetDatabase. LoadAssetAtPath("Assets/RalivDynamicPenetrationSystem/MyData/"+orifice.name+".asset",typeof(Texture2D))); } } } void FindOrificeMaterial(SkinnedMeshRenderer meshRenderer) { for (int i=0;i()==null) { EditorGUILayout.HelpBox("No skinned mesh renderer detected!", MessageType.Error); } else { if (orificeMaterial==null) { FindOrificeMaterial(orifice.GetComponent()); if (orificeMaterial==null) EditorGUILayout.HelpBox("Mesh does not have orifice material!", MessageType.Error); } else { EditorGUILayout.LabelField("Select blendshapes for penetration deformations", textStyle); EditorGUILayout.LabelField("", textStyle); EditorGUILayout.LabelField("Entrance", textStyle); shapes[0] = EditorGUILayout.Popup(shapes[0], blendshapeNameList(orifice.GetComponent().sharedMesh).ToArray()); EditorGUILayout.LabelField("Depth1", textStyle); shapes[1] = EditorGUILayout.Popup(shapes[1], blendshapeNameList(orifice.GetComponent().sharedMesh).ToArray()); EditorGUILayout.LabelField("Depth2", textStyle); shapes[2] = EditorGUILayout.Popup(shapes[2], blendshapeNameList(orifice.GetComponent().sharedMesh).ToArray()); EditorGUILayout.LabelField("Depth3", textStyle); shapes[3] = EditorGUILayout.Popup(shapes[3], blendshapeNameList(orifice.GetComponent().sharedMesh).ToArray()); EditorGUILayout.LabelField("", textStyle); if (GUILayout.Button("Generate Texture")) { CreateTexture(); Close(); } } } } } } #endif