SecretAnorak

Jiggle.cs

May 28th, 2019
1,120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UMA;
  5. using UMA.CharacterSystem;
  6.  
  7. public class Jiggle : MonoBehaviour
  8. {
  9.     [Header("General Settings")]
  10.     public string jiggleBoneName;
  11.     public List<string> exceptions;
  12.     [Range(0,1)]
  13.     public float reduceEffect;
  14.    
  15.     [Header("Removable Bone Settings")]
  16.     public bool deleteBoneWithSlot;
  17.     public string slotToWatch;
  18.     private string linkedRecipe;
  19.    
  20.     public void AddJiggle(UMAData umaData)
  21.     {
  22.         Transform rootBone = umaData.gameObject.transform.FindDeepChild(jiggleBoneName);
  23.         UMABoneCleaner cleaner = umaData.gameObject.GetComponent<UMABoneCleaner>();
  24.        
  25.         if(rootBone != null)
  26.         {          
  27.             DynamicBone jiggleBone = rootBone.GetComponent<DynamicBone>();
  28.             if(jiggleBone == null)
  29.             {
  30.                 jiggleBone = rootBone.gameObject.AddComponent<DynamicBone>();
  31.             }
  32.            
  33.             jiggleBone.m_Root = rootBone;
  34.            
  35.             List<Transform> exclusionList = new List<Transform>();
  36.            
  37.             foreach(string exception in exceptions)
  38.             {
  39.                 exclusionList.Add(umaData.gameObject.transform.FindDeepChild(exception));
  40.             }
  41.            
  42.             jiggleBone.m_Exclusions = exclusionList;
  43.             jiggleBone.m_Inert = reduceEffect;
  44.             jiggleBone.UpdateParameters();
  45.         }
  46.        
  47.         if(deleteBoneWithSlot)
  48.         {
  49.             if(cleaner == null)
  50.                 cleaner = umaData.gameObject.AddComponent<UMABoneCleaner>();
  51.            
  52.             UMAJiggleBoneListing listing = new UMAJiggleBoneListing();
  53.             listing.boneName = jiggleBoneName;
  54.             listing.carrierSlot = slotToWatch;
  55.            
  56.             linkedRecipe = umaData.gameObject.GetComponent<DynamicCharacterAvatar>().GetWardrobeItemName(slotToWatch);
  57.            
  58.             listing.recipe = linkedRecipe;
  59.             cleaner.RegisterJiggleBone(listing);
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment