void Setup(Animations.EditAnimation anim) { base.SetupHeader(false, false, anim.name, SetName); editAnimation = anim; this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(anim.defaultPreviewSettings.design, 600); if (dieRenderer != null) { previewImage.texture = dieRenderer.renderTexture; } rotationSlider.Setup(this.dieRenderer); rotationControl.Setup(this.dieRenderer); animationSelector.Setup( "Lighting Pattern Type", () => editAnimation.type, (t) => SetAnimationType((Animations.AnimationType)t), null); // Setup all other parameters parameters = UIParameterManager.Instance.CreateControls(anim, parametersRoot); parameters.onParameterChanged += OnAnimParameterChanged; dieRenderer.SetAuto(true); dieRenderer.SetAnimation(anim); dieRenderer.Play(true); }
void SetAnimationType(Animations.AnimationType newType) { if (newType != editAnimation.type) { // Change the type, which really means create a new animation and replace the old one var newEditAnimation = Animations.EditAnimation.Create(newType); // Copy over the few things we can newEditAnimation.duration = editAnimation.duration; newEditAnimation.name = editAnimation.name; newEditAnimation.defaultPreviewSettings = editAnimation.defaultPreviewSettings; // Replace the animation AppDataSet.Instance.ReplaceAnimation(editAnimation, newEditAnimation); // Setup the parameters again foreach (var parameter in parameters.parameters) { GameObject.Destroy(parameter.gameObject); } parameters = UIParameterManager.Instance.CreateControls(newEditAnimation, parametersRoot); parameters.onParameterChanged += OnAnimParameterChanged; dieRenderer.SetAuto(true); dieRenderer.SetAnimation(newEditAnimation); editAnimation = newEditAnimation; base.pageDirty = true; } }
void SetConditionType(Behaviors.ConditionType newType) { if (newType != editCondition.type) { onConditionChanged?.Invoke(parentRule, editCondition); // Change the type, which really means create a new condition and replace the old one var newCondition = Behaviors.EditCondition.Create(newType); // Replace the condition parentRule.condition = newCondition; // Setup the parameters again foreach (var parameter in parameters.parameters) { GameObject.Destroy(parameter.gameObject); } parameters = UIParameterManager.Instance.CreateControls(newCondition, parametersRoot); parameters.onParameterChanged += OnConditionChanged; editCondition = newCondition; onConditionChanged?.Invoke(parentRule, editCondition); } }
void OnDestroy() { foreach (var parameter in parameters.parameters) { GameObject.Destroy(parameter.gameObject); } parameters.onParameterChanged -= OnActionChanged; parameters = null; }
public void Setup(Behaviors.EditRule rule, Behaviors.EditCondition condition) { parentRule = rule; editCondition = condition; conditionSelector.Setup( "Condition Type", () => editCondition.type, (t) => SetConditionType((Behaviors.ConditionType)t), null); // Setup all other parameters parameters = UIParameterManager.Instance.CreateControls(condition, parametersRoot); parameters.onParameterChanged += OnConditionChanged; }
public void Setup(Behaviors.EditRule rule, Behaviors.EditAction action, bool first) { parentRule = rule; editAction = action; labelText.text = first ? "Then" : "And"; actionSelector.Setup( "Action Type", () => editAction.type, (t) => SetActionType((Behaviors.ActionType)t), null); // Setup all other parameters parameters = UIParameterManager.Instance.CreateControls(action, parametersRoot); parameters.onParameterChanged += OnActionChanged; }
void OnDisable() { if (DiceRendererManager.Instance != null && this.dieRenderer != null) { DiceRendererManager.Instance.DestroyDiceRenderer(this.dieRenderer); this.dieRenderer = null; } foreach (var parameter in parameters.parameters) { GameObject.Destroy(parameter.gameObject); } parameters = null; if (previewDie != null) { previewDie.die.SetStandardMode(); DiceManager.Instance.DisconnectDie(previewDie, null); previewDie = null; previewDieConnected = false; } }