SHARE
TWEET

Untitled

a guest Jul 17th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public struct PlayerData {
  2.     public int compensator;
  3.     public int silencer;
  4.     ...
  5. }
  6.      
  7. string attachmentName = "compensator";
  8.  
  9. if (PlayerData[attachmentName]) {
  10.     weapon[attachmentName].gameObject.SetActive(true);
  11. }
  12.      
  13. weapon[attachmentName].gameObject.SetActive(true);
  14.      
  15. if (PlayerData[attachmentName]) {
  16.      
  17. public static object GetAttachment(object obj, string fieldName)
  18. {
  19.     return obj.GetType().GetField(fieldName).GetValue(obj);
  20. }
  21.      
  22. GetAttachment(playerData, "compensator");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top