public void changeNif(string newNifP) { try { Debug.Log("Change nif:" + newNifP); string newNif = newNifP; if (newNifP.Contains(":")) { newNif = newNifP.Split(':')[1]; } Model animNifModel = nifDictionary[newNif]; AnimatedNif animNif = gameObject.GetComponent <AnimatedNif>(); if (animNif == null) { animNif = gameObject.AddComponent <AnimatedNif>(); } animNif.setParams(adb, animNifModel.nifFile, animNifModel.kfmFile, animNifModel.kfbFile); this.mount = animNifModel.mount; if (nifmodel != null) { GameObject.DestroyImmediate(nifmodel); } Debug.Log("load nif"); nifmodel = NIFLoader.loadNIF(animNif.nif, true); nifmodel.transform.parent = root.transform; Debug.Log("set anims dropdown"); this.animationDropdown.ClearOptions(); List <String> anims = new List <String>(); foreach (KFAnimation ani in animNif.getAnimations()) { //Debug.Log("Found anim [" + ani.id + "]:" + ani.sequenceFilename + ":" + ani.sequencename ); anims.Add(ani.sequencename); } anims.Sort(); Debug.Log("set skel root"); animNif.setSkeletonRoot(nifmodel); animationNif = animNif; Debug.Log("set active anim"); animationNif.setActiveAnimation(animationNif.getIdleAnimIndex()); this.animationDropdown.AddOptions(anims); Debug.Log("DONE Change nif:" + newNifP); } catch (Exception ex) { Debug.LogError(ex); } }
private void updateRaceGender() { if (state != ClassState.UPDATE) { Debug.LogError("Cannot update race/gender without being update mode"); return; } if (refModel != null) { GameObject.Destroy(refModel); } if (costumeParts != null) { GameObject.Destroy(costumeParts); } // defines the base model string nif = string.Format("{0}_refbare.nif", getBaseModel()); string kfm = string.Format("{0}.kfm", getBaseModel()); string kfb = string.Format("{0}.kfb", getKFBBase()); if (!"".Equals(kfbOverride)) { kfb = kfbOverride; } animationNif = this.gameObject.GetComponent <AnimatedNif>(); if (animationNif == null) { animationNif = this.gameObject.AddComponent <AnimatedNif>(); } animationNif.setParams(AssetDatabaseInst.DB, nif, kfm, kfb); NIFFile file = NIFLoader.getNIF(nif); GameObject go = NIFLoader.loadNIF(file, nif, true); go.transform.parent = this.transform; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; refModel = go; if (!"".Equals(animOverride)) { animationNif.setActiveAnimation(animOverride); } else { string animation = string.Format("{0}_{1}_idle", getBaseModel(), getAnimationSet()); try { animationNif.setActiveAnimation(animation); } catch (Exception ex) { Debug.LogError("Unable to load animation:" + animation); } } animationNif.setSkeletonRoot(refModel); costumeParts = new GameObject("CostumeParts"); costumeParts.transform.parent = refModel.transform; }