Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public struct PlayerData {
- public int compensator;
- public int silencer;
- ...
- }
- string attachmentName = "compensator";
- if (PlayerData[attachmentName]) {
- weapon[attachmentName].gameObject.SetActive(true);
- }
- weapon[attachmentName].gameObject.SetActive(true);
- if (PlayerData[attachmentName]) {
- public static object GetAttachment(object obj, string fieldName)
- {
- return obj.GetType().GetField(fieldName).GetValue(obj);
- }
- GetAttachment(playerData, "compensator");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement