Panel for editing a controllable policy
Inheritance: MonoBehaviour
Exemplo n.º 1
0
        /// <summary>
        /// Initialization method
        /// </summary>
        /// <param name="parent">Parent policy edit panel, which includes this entry</param>
        /// <param name="validActions">Actions that are valid for this entry</param>
        /// <param name="validStates">States that are valid for this entry</param>
        /// <param name="currentAction">Currently selected action of this entry</param>
        /// <param name="currentValue">Current value of this entry</param>
        public void Initialize(PolicyEditPanel parent, List <string> validActions, List <string> validStates,
                               string currentAction, string currentValue)
        {
            parentPanel = parent;
            actionDropdown.ClearOptions();
            actionDropdown.AddOptions(validActions);
            if (!validActions.Contains(currentAction))
            {
                currentAction = validActions[0];
            }
            var actionId = validActions.IndexOf(currentAction);

            actionDropdown.SetValueWithoutNotify(actionId);
            ActionChanged(currentAction);
            valueDropdown.ClearOptions();
            valueDropdown.AddOptions(validStates);
            switch (currentAction)
            {
            case "state":
                if (!validStates.Contains(currentValue))
                {
                    currentValue = validStates[0];
                }
                var valueId = validStates.IndexOf(currentValue);
                Value = currentValue;
                valueDropdown.SetValueWithoutNotify(valueId);
                break;

            default:
                Value = currentValue;
                valueInput.SetTextWithoutNotify(currentValue);
                break;
            }

            UpdatePolicy(Value);
            IsInitialized = true;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Deinitalizes the policy entry
 /// </summary>
 public void Deinitialize()
 {
     parentPanel   = null;
     IsInitialized = false;
 }