static void OnSceneSaved(Scene scene, string s) { if (GestureDisplay.getVRCSceneAvatar() != null) { KAPProfile kp = new KAPProfile(GestureDisplay.getVRCSceneAvatar()); kp.saveFile(); } else { Debug.LogWarning("your avatar is hidden! you might make him visible again, so that KAP can save his performance statistics..."); } }
void OnGUI() { scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Width(position.width), GUILayout.Height(position.height - 74)); GuiLine(2); KAPProfile[] kps = KAPProfile.getAllInProject(); foreach (KAPProfile item in kps) { AvatarsContainer.initKPValue(item.name); addButton("avatar", 3, 0, 20, true); GUILayout.Label(" " + item.name, EditorStyles.boldLabel); GUI.color = PerformanceProfile.doubleToPerfColor(item.perfP.performance()); Rect r = EditorGUILayout.BeginVertical(); EditorGUI.ProgressBar(r, ((4 - item.perfP.performance()) / 4), PerformanceProfile.doubleToPerfName(item.perfP.performance()) + " (" + (4 - item.perfP.performance()) + ")"); GUILayout.Space(18); EditorGUILayout.EndVertical(); GUI.color = Color.white; AvatarsContainer.kpsfoldout[item.name] = EditorGUILayout.Foldout(AvatarsContainer.kpsfoldout[item.name], "details"); if (AvatarsContainer.kpsfoldout[item.name]) { GUILayout.BeginHorizontal(); addPerfSection(item.polys, item.perfP.polysperf, "polygon"); DrawBreak(); addPerfSection(item.boneamount, item.perfP.boneamountperf, "bone"); GUILayout.EndHorizontal(); GuiLine(); GUILayout.BeginHorizontal(); addPerfSection(item.meshrenderers, item.perfP.meshrenderersperf, "mesh"); DrawBreak(); addPerfSection(item.dynboneamount, item.perfP.dynboneamountperf, "dynamic_bone"); GUILayout.EndHorizontal(); GuiLine(); GUILayout.BeginHorizontal(); addPerfSection(item.dynbonecolliders, item.perfP.dynbonecollidersperf, "dynamic_bone_collider"); DrawBreak(); addPerfSection(item.particle_systems, item.perfP.particle_systemsperf, "particle"); GUILayout.EndHorizontal(); GuiLine(); GUILayout.BeginHorizontal(); addPerfSection(item.audio_sources, item.perfP.audio_sourcesperf, "audio"); DrawBreak(); addPerfSection(item.lights, item.perfP.lightsperf, "light_source"); GUILayout.EndHorizontal(); GuiLine(); GUILayout.BeginHorizontal(); addPerfSection(item.animators, item.perfP.animatorsperf, "animator"); DrawBreak(); addPerfSection(item.cloth, item.perfP.clothperf, "cloth"); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); AvatarsContainer.kpsscene[item.name] = GUILayout.Button("scene"); AvatarsContainer.kpsfolder[item.name] = GUILayout.Button("folder"); GUI.backgroundColor = MainContainer.fromRGB(255f, 119f, 110f); AvatarsContainer.kpsdelete[item.name] = GUILayout.Button("delete"); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); } GuiLine(2); if (AvatarsContainer.kpsscene[item.name]) { item.openScene(); } if (AvatarsContainer.kpsfolder[item.name]) { item.openFolder(); CleanFolder.cleanFolder(item.name); } if (AvatarsContainer.kpsdelete[item.name]) { item.delete(); } } GUILayout.EndScrollView(); addButton("avatar", 3, 0, 20, true); GUILayout.Label(" add avatar", EditorStyles.boldLabel); model = (GameObject)EditorGUILayout.ObjectField("select your avatar:", model, typeof(GameObject), true); if (model != null) { bool btn = GUILayout.Button("do it!"); if (btn == true) { AvatarStructureBuilder.BuildOverride(model); } } else { GUI.enabled = false; GUILayout.Button("please select a .fbx"); GUI.enabled = true; } }
public static void BuildOverride(GameObject selected) { progressval = 0f; updateProgressBar("generating folders...", 0.0f); EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); nameval = selected.name; if (!AssetDatabase.IsValidFolder("Assets/KAPAvatars/" + nameval)) { AssetDatabase.CreateFolder("Assets/KAPAvatars", nameval); } createKAPFolder("Animations"); createKAPFolder("Audio"); createKAPFolder("Materials"); createKAPFolder("Textures"); createKAPFolder("Shaders"); createKAPFolder("Controllers"); //Generated Folders updateProgressBar("copying avatar...", 1.0f); string sourcepath = AssetDatabase.GetAssetPath(selected); AssetDatabase.CopyAsset(sourcepath, "Assets/KAPAvatars/" + nameval + "/" + nameval + ".fbx"); //Copied Avatar updateProgressBar("generating animation files...", 1.0f); CreateAnimationFiles(nameval); //Generated Animation Files updateProgressBar("instantiating avatar...", 1.0f); EditorApplication.NewScene(); GameObject newobj = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/KAPAvatars/" + nameval + "/" + nameval + ".fbx", typeof(GameObject)); newobj = (GameObject)Instantiate(newobj, new Vector3(0, 0, 0), Quaternion.identity); //Instantiated Avatar updateProgressBar("instantiating viewpointsetter...", 1.0f); GameObject view = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/KorikasAvatarPlugin/Korikas Avatar Plugin/Examples/Prefabs/ViewpointSetter.prefab", typeof(GameObject)); view = (GameObject)Instantiate(view, new Vector3(0, 0, 0), Quaternion.identity); view.name = "ViewpointSetter"; //Instantiated ViewpointSetter updateProgressBar("creating KAPprofile...", 1.0f); newobj.name = nameval; KAPProfile kp = new KAPProfile(newobj); kp.saveFile(); //Created KAPprofile updateProgressBar("deleting old file and adding the VRC_AvatarDescriptor...", 1); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(selected)); VRC_AvatarDescriptor vrcad = newobj.AddComponent(typeof(VRC_AvatarDescriptor)) as VRC_AvatarDescriptor; AnimatorOverrideController Ovrd = (AnimatorOverrideController)AssetDatabase.LoadAssetAtPath("Assets/KAPAvatars/" + nameval + "/" + nameval + ".overrideController", typeof(AnimatorOverrideController)); vrcad.CustomSittingAnims = Ovrd; vrcad.CustomStandingAnims = Ovrd; addLipSync(newobj); //Deleted old File and added the VRC_AvatarDescriptor updateProgressBar("saving scene and refreshing files...", 1.0f); EditorApplication.SaveScene("Assets/KAPAvatars/" + nameval + "/" + nameval + ".unity"); AssetDatabase.Refresh(); //Saved Scene and refreshed Files EditorUtility.ClearProgressBar(); }