Advertisement
apieceoffruit

GameSettings

Jul 6th, 2022
1,105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. using AnomieUtilities;
  2. using UnityEngine;
  3.  
  4. namespace JasonStorey
  5. {
  6.     [CreateAssetMenu(menuName = "Create GameSettings", fileName = "GameSettings", order = 0)]
  7.     public class GameSettings : MonitoredSo
  8.     {
  9.         [SerializeField]
  10.         string environment;
  11.  
  12.         [SerializeField,Range(0,100)]
  13.         int amount;
  14.  
  15.         [SerializeField]
  16.         bool someToggle;
  17.        
  18.         [SerializeField]
  19.         Vector3 SomePosition { get; set; }
  20.        
  21.         public bool SomeToggle
  22.         {
  23.             get => someToggle;
  24.             set
  25.             {
  26.                 someToggle = value;
  27.                 OnPropertyChanged();
  28.             }
  29.         }
  30.  
  31.         public int Amount
  32.         {
  33.             get => amount;
  34.             set
  35.             {
  36.                 amount = value;
  37.                 OnPropertyChanged();
  38.             }
  39.         }
  40.  
  41.         public string Environment
  42.         {
  43.             get => environment;
  44.             set
  45.             {
  46.                 environment = value;
  47.                 OnPropertyChanged();
  48.             }
  49.         }
  50.  
  51.         void OnValidate()
  52.         {
  53.             if(!Application.isPlaying) return;
  54.             Environment = environment;
  55.             Amount = amount;
  56.             SomeToggle = someToggle;
  57.             SomePosition = SomePosition;
  58.         }
  59.        
  60.         protected override void SaveValue(MonitoredSettings settings, string prop) => HandleProperty(this, prop);
  61.  
  62.     }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement