public LabelWithToggles Init(string mainLabelStr, params string[] names)
        {
            if (subItems != null)
            {
                DestroySubItems();
            }

            mainLabel.text = mainLabelStr;

            int i            = 0;
            var subItemsList =
                DotNETCoreCompat.ConvertAll(
                    names,
                    n =>
            {
                if (string.IsNullOrEmpty(n))
                {
                    return(null);
                }

                var lwt = (Instantiate(_SubItemPrefab.gameObject) as GameObject).GetComponent <LabelWithToggle>();
                lwt.gameObject.SetActive(true);
                lwt.transform.SetParent(toggleGroup.transform, false);
                lwt.Init(n);
                toggleGroup.RegisterToggle(lwt.toggle);

                var copyOfI = i++;

                lwt.toggle.onValueChanged.AddListener(isOn =>
                {
                    if (ToggleChanged != null)
                    {
                        ToggleChanged(copyOfI, isOn);
                    }
                });

                return(lwt);
            }
                    );

            // Only keep the non-null ones (the ones with names)
            subItems = subItemsList.FindAll(si => si != null).ToArray();

            return(this);
        }
Ejemplo n.º 2
0
        void Call(string methodName, params object[] parameters)
        {
            if (_AdapterImpl == null)
            {
                return;
            }

            Type t = GetBaseType();

            //foreach (var m in t.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
            //	if (m.Name.ToLower().Contains("compute"))
            //	Debug.Log(m);

            var mi = t.GetMethod(
                methodName,
                BINDING_FLAGS,
                null,
                DotNETCoreCompat.ConvertAllToArray(parameters, p => p.GetType()),
                null
                );

            mi.Invoke(_AdapterImpl, parameters);
        }