public void ApplyCachedValues(GUIValueCache cache)
 {
     foreach (var field in fields)
     {
         field.ApplyCachedValue(cache);
     }
 }
 public static void EndFieldGroup(GUIValueCache cache)
 {
     if (currentGroup == null)
     {
         Debug.LogError("Tried to end a GUI Field Group but there wasn't a 'BeginFieldGroup' call");
         return;
     }
     if (currentGroup.editMode && GUILayout.Button("Apply"))
     {
         currentGroup.ApplyCachedValues(cache);
     }
     currentGroup = null;
 }
 public override void ApplyCachedValue(GUIValueCache cache)
 {
     if (cache.TryGetValueForKey(Name, out object value))
     {
         if (value is Vector3 lastVector)
         {
             Setter(lastVector);
         }
         else
         {
             Debug.LogWarning("lastValue for Float Field " + Name + " is not a Vector3!");
         }
     }
     else
     {
         Debug.LogWarning("No lastValue found for Field " + Name + "!");
     }
 }
        public static bool Vector3Field(string name, GUIValueCache cache, Func <Vector3> getter, Action <Vector3> setter, float saveButtonWidth = 40f)
        {
            if (currentGroup != null)
            {
                currentGroup.AddVector3Field(name, setter);
            }
            bool didSave = false;

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label(name);
            if (!cache.ContainsValueForKey(name))
            {
                cache.valuesDict.Add(name, getter());
            }
            Vector3 vector = (Vector3)cache.valuesDict[name];
            float   x      = vector.x;
            float   y      = vector.y;
            float   z      = vector.z;

            float.TryParse(GUILayout.TextField(x.ToString("0.00")), out x);
            float.TryParse(GUILayout.TextField(y.ToString("0.00")), out y);
            float.TryParse(GUILayout.TextField(z.ToString("0.00")), out z);
            Vector3 newValue = new Vector3(x, y, z);

            cache.valuesDict[name] = newValue;
            GUILayout.EndVertical();
            if (currentGroup == null)
            {
                if (GUILayout.Button("Apply", GUILayout.ExpandHeight(true), GUILayout.Width(saveButtonWidth)))
                {
                    setter(newValue);
                    didSave = true;
                }
            }
            GUILayout.EndHorizontal();
            return(didSave);
        }
        public static bool IntField(string name, GUIValueCache cache, Func <int> getter, Action <int> setter, int min = 0, int max = 10, float saveButtonWidth = 40f)
        {
            if (currentGroup != null)
            {
                currentGroup.AddIntField(name, setter);
            }
            bool didSave = false;

            if (!cache.ContainsValueForKey(name))
            {
                cache.valuesDict.Add(name, getter());
            }
            int num = (int)cache.valuesDict[name];

            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical();
                {
                    GUILayout.Label(name);
                    int.TryParse(GUILayout.TextField(num.ToString("0")), out num);
                    num = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)num, (float)min, (float)max));
                    cache.valuesDict[name] = num;
                }
                GUILayout.EndVertical();
                if (currentGroup == null)
                {
                    if (GUILayout.Button("Apply", GUILayout.ExpandHeight(true), GUILayout.Width(saveButtonWidth)))
                    {
                        setter(num);
                        didSave = true;
                    }
                }
            }
            GUILayout.EndHorizontal();
            return(didSave);
        }
 public abstract void ApplyCachedValue(GUIValueCache cache);