public StateBinding(StateBinding original) { if (original != null) { _stateEntered = new SerializableStateReference(original._stateEntered); _parameter = new SerializableAnimatorControllerParameter(original._parameter); _isDelayed = original._isDelayed; _delayTime = original._delayTime; } }
private void DrawMassNewButton() { if (GUILayout.Button("Mass New") && Event.current.button == 0) // Only on left click { MarkDirty(); var newBinding = new StateBinding(); switch (_currentFilter) { case Filter.ShowAll: for (int i = 1; i < _broadcasterStates.Length; i++) { newBinding.StateEntered = _broadcasterStates[i]; for (int j = 1; j < _receiverParameters.Length; j++) { newBinding.Parameter = _receiverParameters[j]; _stateBinder.StateBindings.Add(new StateBinding(newBinding)); } } break; case Filter.StateEntered: newBinding.StateEntered = _broadcasterStates[_filterIndex]; for (int i = 1; i < _receiverParameters.Length; i++) { newBinding.Parameter = _receiverParameters[i]; _stateBinder.StateBindings.Add(new StateBinding(newBinding)); } break; case Filter.ParameterName: newBinding.Parameter = _receiverParameters[_filterIndex]; for (int i = 1; i < _broadcasterStates.Length; i++) { newBinding.StateEntered = _broadcasterStates[i]; _stateBinder.StateBindings.Add(new StateBinding(newBinding)); } break; case Filter.ParameterType: for (int i = 1; i < _receiverParameters.Length; i++) { if (_receiverParameters[i].Type == (AnimatorControllerParameterType)_filterIndex) { newBinding.Parameter = _receiverParameters[i]; for (int j = 1; j < _broadcasterStates.Length; j++) { newBinding.StateEntered = _broadcasterStates[j]; _stateBinder.StateBindings.Add(new StateBinding(newBinding)); } } } break; } } }
private void DrawStateBinding(StateBinding stateBinding, int stateIndex, int parameterIndex) { GUILayout.BeginVertical("Box"); GUI.backgroundColor = _defaultBackgroundColor; // State GUI var selectedStateIndex = EditorGUILayout.Popup("State Entered", stateIndex, _broadcasterStateNames); // Param GUI var selectedParameterIndex = EditorGUILayout.Popup("Parameter", parameterIndex, _receiverParameterNames); DrawParameter(stateBinding.Parameter); // Delay GUI GUI.enabled = stateBinding.Parameter.Name != Unassigned; var isDelayed = EditorGUILayout.Toggle("Is Delayed", stateBinding.IsDelayed); GUI.enabled = stateBinding.Parameter.Name != Unassigned && stateBinding.IsDelayed; var delayTime = EditorGUILayout.DelayedFloatField("Seconds Delayed", stateBinding.DelayTime); GUI.enabled = true; // Apply State Changes if (selectedStateIndex != stateIndex) { MarkDirty(); stateBinding.StateEntered = _broadcasterStates[selectedStateIndex]; // Bump to the first valid parameter when setting a state if (selectedParameterIndex == 0 && _receiverParameters.Length > 1) { selectedParameterIndex = 1; } } // Apply Param Changes if (selectedParameterIndex != parameterIndex) { MarkDirty(); stateBinding.Parameter = new SerializableAnimatorControllerParameter(_receiverParameters[selectedParameterIndex]); } // Apply Delay Changes if (isDelayed != stateBinding.IsDelayed) { MarkDirty(); stateBinding.IsDelayed = isDelayed; } if (delayTime != stateBinding.DelayTime) { MarkDirty(); stateBinding.DelayTime = delayTime; } GUILayout.EndVertical(); }
private bool IncludedInFilter(StateBinding stateBinding, int stateIndex, int parameterIndex) { switch (_currentFilter) { case Filter.StateEntered: return(stateIndex == _filterIndex); case Filter.ParameterName: return(parameterIndex == _filterIndex); case Filter.ParameterType: return(stateBinding.Parameter.Type == (AnimatorControllerParameterType)_filterIndex); default: return(true); } }
private void ContextDuplicateAcross(object indexObj) { int index = (int)indexObj; if (_broadcasterStates.Length > 2 && 0 <= index && index < _stateBinder.StateBindings.Count) { MarkDirty(); var original = _stateBinder.StateBindings[index]; int originalStateIndex = GetStateIndex(original.StateEntered); for (int i = 1; i < _broadcasterStates.Length; i++) { if (i != originalStateIndex) { var duplicate = new StateBinding(original); duplicate.StateEntered = _broadcasterStates[i]; _stateBinder.StateBindings.Add(duplicate); } } } }
private void DrawNewBindingButton() { if (GUILayout.Button("New") && Event.current.button == 0) // Only on left click { MarkDirty(); var newBinding = new StateBinding(); switch (_currentFilter) { case Filter.StateEntered: newBinding.StateEntered = new SerializableStateReference(_broadcasterStates[_filterIndex]); break; case Filter.ParameterName: newBinding.Parameter = new SerializableAnimatorControllerParameter(_receiverParameters[_filterIndex]); break; case Filter.ParameterType: newBinding.Parameter = new SerializableAnimatorControllerParameter(type: (AnimatorControllerParameterType)_filterIndex); break; } _stateBinder.StateBindings.Add(newBinding); } }