Exemplo n.º 1
0
        public PlaceholderPageViewModel()
        {
            EffectOn.Value = true;


            ColorToggle.Subscribe(x => {
                PlaceColor.Value = x ? Color.Silver : Color.Red;
            });

            TextToggle.Subscribe(x => {
                PlaceText.Value = x ? "Placeholder Text" :
                                  "Placeholder Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text End";
            });

            ColorToggle.Value = true;
            TextToggle.Value  = true;

            ChangeTextCommand.Subscribe(_ => {
                if (string.IsNullOrEmpty(EditText.Value))
                {
                    EditText.Value = "Abcdef";
                }
                else
                {
                    EditText.Value = "";
                }
            });
        }
Exemplo n.º 2
0
 private void ValidateToggleIsInGroup(ColorToggle toggle)
 {
     if (toggle == null || !m_Toggles.Contains(toggle))
     {
         throw new ArgumentException(string.Format("Toggle {0} is not part of ToggleGroup {1}", new object[] { toggle, this }));
     }
 }
 // Use this for initialization
 void Start()
 {
     // Bit shift the index of the layers to get a bit mask
     buildingLayerMask = 1 << buildingLayer;
     dragonLayerMask   = ~(1 << dragonLayer);
     flames            = ( FlameController[] )Object.FindObjectsOfType(typeof(FlameController));
     targetColor       = pointer.gameObject.GetComponent <ColorToggle>();
 }
Exemplo n.º 4
0
    private void ToggleClicked(ColorToggle toggle)
    {
        if (toggle == currentToggle)
        {
            return;
        }

        Select(toggle);
        OnColorChanged?.Invoke(currentToggle.color);
    }
Exemplo n.º 5
0
    public void Select(Color color)
    {
        ColorToggle toggle = GetColorToggle(color);

        if (toggle == currentToggle)
        {
            return;
        }
        Select(toggle);
    }
Exemplo n.º 6
0
    public void Populate(IReadOnlyList <Color> colors)
    {
        int colorNumber = colors.Count;

        for (int i = 0; i < colorNumber; ++i)
        {
            ColorToggle newToggle = Instantiate(colorTogglePrefab, colorContainer);
            newToggle.Initialize(colors[i], false);
            newToggle.OnClicked += ToggleClicked;
            colorToggles.Add(newToggle);
        }
    }
Exemplo n.º 7
0
        /// <summary>
        /// Register a toggle with the toggle group so it is watched for changes and notified if another toggle in the group changes.
        /// </summary>
        /// <param name="toggle">The toggle to register with the group.</param>
        public void RegisterToggle(ColorToggle toggle)
        {
            if (!m_Toggles.Contains(toggle))
            {
                m_Toggles.Add(toggle);
            }

            if (!allowSwitchOff && !AnyTogglesOn())
            {
                toggle.isOn = true;
                NotifyToggleOn(toggle);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Unregister a toggle from the group.
        /// </summary>
        /// <param name="toggle">The toggle to remove.</param>
        public void UnregisterToggle(ColorToggle toggle)
        {
            if (m_Toggles.Contains(toggle))
            {
                m_Toggles.Remove(toggle);
            }

            if (!allowSwitchOff && !AnyTogglesOn() && m_Toggles.Count != 0)
            {
                m_Toggles[0].isOn = true;
                NotifyToggleOn(m_Toggles[0]);
            }
        }
Exemplo n.º 9
0
    private void Select(ColorToggle colorToggle)
    {
        if (currentToggle != null)
        {
            currentToggle.selected = false;
        }

        currentToggle = colorToggle;

        if (colorToggle)
        {
            colorToggle.selected = true;
        }
    }
Exemplo n.º 10
0
    private void Awake()
    {
        if (layoutGroup == null)
        {
            return;
        }

        for (int i = 0; i < maxStars; i++)
        {
            ColorToggle color = Instantiate(starPrefab, layoutGroup.transform).GetComponent <ColorToggle>();
            color.OnToggle += SetStars;
            stars.Add(color);
        }
    }
Exemplo n.º 11
0
    public void SelectRandom()
    {
        if (colorToggles.Count == 0)
        {
            return;
        }

        ColorToggle toggle = colorToggles[Random.Range(0, colorToggles.Count)];

        if (toggle == currentToggle)
        {
            return;
        }

        Select(toggle);
        OnColorChanged?.Invoke(currentToggle.color);
    }
Exemplo n.º 12
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            EditorGUILayout.Space();

            serializedObject.Update();
            ColorToggle toggle = serializedObject.targetObject as ColorToggle;

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_IsOnProperty);
            if (EditorGUI.EndChangeCheck())
            {
                EditorSceneManager.MarkSceneDirty(toggle.gameObject.scene);
                ColorToggleGroup group = m_GroupProperty.objectReferenceValue as ColorToggleGroup;

                toggle.isOn = m_IsOnProperty.boolValue;

                if (group != null && toggle.IsActive())
                {
                    if (toggle.isOn || (!group.AnyTogglesOn() && !group.allowSwitchOff))
                    {
                        toggle.isOn = true;
                        group.NotifyToggleOn(toggle);
                    }
                }
            }
            EditorGUILayout.PropertyField(m_TransitionProperty);
            EditorGUILayout.PropertyField(m_GraphicProperty);
            EditorGUILayout.PropertyField(m_BlockColor);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_GroupProperty);
            if (EditorGUI.EndChangeCheck())
            {
                EditorSceneManager.MarkSceneDirty(toggle.gameObject.scene);
                ColorToggleGroup group = m_GroupProperty.objectReferenceValue as ColorToggleGroup;
                toggle.group = group;
            }

            EditorGUILayout.Space();

            // Draw the event notification options
            EditorGUILayout.PropertyField(m_OnValueChangedProperty);

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 13
0
    private void SetStars(ColorToggle colorToggle)
    {
        int indexOfToggledStar = stars.IndexOf(colorToggle);

        foreach (var star in stars)
        {
            if (colorToggle.IsOff &&
                star.transform.GetSiblingIndex() > indexOfToggledStar)
            {
                star.TurnOff();
            }

            else if (star.transform.GetSiblingIndex() < indexOfToggledStar)
            {
                star.TurnOn();
            }
        }

        colorToggle.TurnOn();
    }
Exemplo n.º 14
0
        /// <summary>
        /// Notify the group that the given toggle is enabled.
        /// </summary>
        /// <param name="toggle">The toggle that got triggered on</param>
        public void NotifyToggleOn(ColorToggle toggle, bool sendCallback = true)
        {
            ValidateToggleIsInGroup(toggle);
            // disable all toggles in the group
            for (var i = 0; i < m_Toggles.Count; i++)
            {
                if (m_Toggles[i] == toggle)
                {
                    continue;
                }

                if (sendCallback)
                {
                    m_Toggles[i].isOn = false;
                }
                else
                {
                    m_Toggles[i].SetIsOnWithoutNotify(false);
                }
            }
        }
Exemplo n.º 15
0
 public AlterColorPageViewModel()
 {
     ColorToggle.Subscribe(x => {
         Accent.Value = x ? Color.FromHex("#2455b3") : Color.FromHex("#CCA3B0");
     });
 }