SaintsField: Expandable doesn't update the SO value when nested in Unity 2020
with this setup changing expanded team within the editor doesn’t update the SO and colored progressbars don’t follow color coding set by FillColor():
[Expandable, Required]
public MCTeam team;
and that
public enum ALIANCETYPE { FRIEND, NEUTRAL, ENEMY }
[CreateAssetMenu]
public class MCTeam : ScriptableObject
{
[Tooltip("for physics raycast, <everything> is fine but setting it can help optimize")]
public LayerMask layers;
public List<TeamCounter> aliances;
[MinMaxSlider(-10, 10)]
public Vector2 neutralRange = new Vector2(-1, 1);
#if UNITY_EDITOR
void OnValidate()
{
for (var i = aliances.Count - 1; i >= 0; i--) {
var a = aliances[i];
a.neutralRange = neutralRange;
if (a.team == this) aliances.RemoveAt(i);
if (aliances.FindAll(tt => tt.team == a.team).Count > 1) a.team = null;
}
}
#endif
public ALIANCETYPE GetAliance(MCTeam t) => aliances.Find(a => a.team == t).aliance;
public ALIANCETYPE AddliancePoints(MCTeam t, int points)
{
TeamCounter teamCounter = aliances.Find(a => a.team == t);
teamCounter.affinity += points;
return teamCounter.aliance;
}
[Serializable]
public class TeamCounter
{
[Layout("ream counter", ELayout.Horizontal)]
[Required]
public MCTeam team;
[ProgressBar(-20, 20, step: 0.1f, colorCallback: nameof(FillColor))]
public int affinity;
public ALIANCETYPE aliance
{
get {
if (affinity > neutralRange.y) return ALIANCETYPE.FRIEND;
else if (affinity < neutralRange.x) return ALIANCETYPE.ENEMY;
else return ALIANCETYPE.NEUTRAL;
}
}
[HideInInspector]
public Vector2 neutralRange;
#if UNITY_EDITOR
private EColor FillColor() => aliance == ALIANCETYPE.ENEMY ? EColor.Red : (aliance == ALIANCETYPE.FRIEND ? EColor.Green : EColor.Gray);
#endif
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (10 by maintainers)
Commits related to this issue
- reproduce #60 — committed to TylerTemp/SaintsField by TylerTemp 2 years ago
- IMGUI progressBar array shared drawer status issue #60 — committed to TylerTemp/SaintsField by TylerTemp 2 years ago
This issue is (supposed to be) fixed in 3.4.9. Closed as fixed. If you still face a similar issue please comment below and I will re-open it.
Hi, please check if it’s been fixed in 3.2.3