public static void ShowWindow() { AvatarStructureBuilder.createKAPRootFolder(); EditorWindow window = EditorWindow.GetWindow <AvatarsUI>("KAPAvatars"); window.minSize = new Vector2(265, 265); }
public static void generateBeatAnimation(TextAsset text, float zoom, float blur, Color beatcolor, Color betweencolor, AudioClip audio) { GameObject source = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/KorikasAvatarPlugin/Korikas Avatar Plugin/Examples/Prefabs/BeatFinderPrefab.prefab", typeof(GameObject)); string name = source.name; source = (GameObject)Instantiate(source, new Vector3(0, 0, 0), Quaternion.identity); source.name = name; float[] fl = textToFloatArray(text); AnimationClip ac = new AnimationClip(); ac.legacy = true; AddKeyFrames(typeof(MeshRenderer), fl, ac, "material._blurfactor", "zoom", 0f, blur, 0.5f); AddKeyFrames(typeof(MeshRenderer), fl, ac, "material._mag", "zoom", 1f, zoom, 0.5f); AddKeyFrames(typeof(GameObject), fl, ac, "m_IsActive", "trigger", 0f, 0.01f, 0.5f); AddKeyFrames(typeof(MeshRenderer), fl, ac, "material._greenvalue", "zoom", betweencolor.g, beatcolor.g, 0.5f); AddKeyFrames(typeof(MeshRenderer), fl, ac, "material._bluevalue", "zoom", betweencolor.b, beatcolor.b, 0.5f); AddKeyFrames(typeof(MeshRenderer), fl, ac, "material._redvalue", "zoom", betweencolor.r, beatcolor.r, 0.5f); AddKeyFrames(typeof(ParticleSystem), fl, ac, "simulationSpeed", "example", 0.5f, 1f, 0.5f); ac.legacy = false; AvatarStructureBuilder.createFolder("Assets", "KAPBeatFinderAnimations"); AssetDatabase.CreateAsset(ac, "Assets/KAPBeatFinderAnimations/" + audio.name + ".anim"); source.GetComponent <AudioSource>().clip = audio; Animator a = source.GetComponent <Animator>(); UnityEditor.Animations.AnimatorController acnew = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath("Assets/KAPBeatFinderAnimations/" + audio.name + ".controller"); a.runtimeAnimatorController = acnew; AnimatorController anc = a.runtimeAnimatorController as AnimatorController; GestureDisplay.addMotionToControllerByPath("Assets/KAPBeatFinderAnimations/" + audio.name + ".anim", anc); }
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; } }