Exemple #1
0
        /// <inheritdoc/>
        protected override void Awake()
        {
            // Make room at the start (top or left) for the header. It's important to set this before the adapter is initialized,
            // because it caches the padding value during that time and only re-reads it from params when major events happen, like a resizing of the ScrollView
            var ctPad    = _Params.ContentPadding;
            int padToSet = (int)(_Params.Table.ColumnsTupleSize + _Params.Table.ColumnsTupleSpacing + .5f);

            if (IsHorizontal)
            {
                ctPad.left = padToSet;
            }
            else
            {
                ctPad.top = padToSet;
            }

            _Header = CreateHeaderViewsHolder();
            if (_Params.Table.ColumnsScrollbar)
            {
                _Header.Adapter.TupleParameters.Scrollbar = _Params.Table.ColumnsScrollbar;
                _ScrollbarFixerColumns = OSAUtil.ConfigureDinamicallyCreatedScrollbar(
                    _Params.Table.ColumnsScrollbar,
                    _Header.Adapter,
                    _Header.Adapter.TupleParameters.Viewport,
                    false
                    );
            }

            if (_Params.Scrollbar)
            {
                _ScrollbarFixerTuples = _Params.Scrollbar.GetComponent <ScrollbarFixer8>();
            }

            base.Awake();
        }
Exemple #2
0
        protected void DisableOrNotifyAboutMiscComponents(GameObject go, string nameToUse, params System.Type[] typesToIgnore)
        {
            var components = go.GetComponents <Component>();

            foreach (var comp in components)
            {
                if (comp is Transform)
                {
                    continue;
                }
                if (comp is CanvasRenderer)
                {
                    continue;
                }
                if (comp is Image)
                {
                    continue;
                }
                if (System.Array.Exists(typesToIgnore, t => OSAUtil.DotNETCoreCompat_IsAssignableFrom(t, comp.GetType())))
                {
                    continue;
                }
                var mb = comp as MonoBehaviour;
                if (mb)
                {
                    if (mb.enabled)
                    {
                        Debug.Log("OSA: Disabling unknown component " + mb.GetType().Name + " on " + nameToUse + ". You can enable it back if it doesn't interfere with OSA");
                        mb.enabled = false;
                    }
                    continue;
                }

                Debug.Log("OSA: Found unknown component '" + comp.GetType().Name + "' on " + nameToUse + ". Make sure it doesn't interfere with OSA");
            }
        }
Exemple #3
0
        public static void GetAvailableOSAImplementations(List <Type> list, bool excludeExampleImplementations, Type implementedInterface = null, Type withoutImplementedInterface = null)
        {
            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (var type in assembly.GetTypes())
                {
                    if (type.IsAbstract)
                    {
                        continue;
                    }
                    if (!type.IsClass)
                    {
                        continue;
                    }
                    if (type.IsGenericType)
                    {
                        continue;
                    }
                    if (type.IsNested)
                    {
                        continue;
                    }
                    if (type.IsNotPublic)
                    {
                        continue;
                    }
                    if (!CWiz.IsSubclassOfOSA(type))
                    {
                        continue;
                    }
                    if (excludeExampleImplementations &&
                        (
                            type.Name.ToLower().Contains("example")
                            ////|| type.Name == typeof(Demos.SimpleExample.SimpleTutorial).Name
                            //|| type.Name == "SimpleExample"
                            //|| type.Name == typeof(CustomAdapters.DateTimePicker.DateTimePickerAdapter).Name
                            || type.Name == "DateTimePickerAdapter"
                        ))
                    {
                        continue;
                    }

                    // Excluding TableView's base classes, which will be used automatically
                    if (type.Name == "BasicHeaderTupleAdapter" ||
                        type.Name == "BasicTupleAdapter")
                    {
                        continue;
                    }

                    if (implementedInterface != null)
                    {
                        if (!OSAUtil.DotNETCoreCompat_IsAssignableFrom(implementedInterface, type))
                        {
                            continue;
                        }
                    }
                    if (withoutImplementedInterface != null)
                    {
                        if (OSAUtil.DotNETCoreCompat_IsAssignableFrom(withoutImplementedInterface, type))
                        {
                            continue;
                        }
                    }

                    list.Add(type);
                }
            }
        }
Exemple #4
0
        public void ConfigureNewAdapter(IOSA adapter)
        {
            var tableAdapter = adapter as ITableAdapter;
            var p            = tableAdapter.TableParameters;
            var transform    = tableAdapter.AsMonoBehaviour.transform;

            p.Viewport = transform.Find("Viewport") as RectTransform;
            p.Content  = p.Viewport.Find("Content") as RectTransform;

            var pTable                    = p.Table;
            var prefabsParent             = transform.Find("Prefabs-Hidden");
            var tuplePrefabsParent        = prefabsParent.Find("Tuple") as RectTransform;
            var columnsTuplePrefabsParent = prefabsParent.Find("ColumnsTuple") as RectTransform;
            var paths = CWiz.TV.Paths;

            // Some recommended spacing values
            p.ContentSpacing = 2;
            if (!p.IsHorizontal)
            {
                p.ContentPadding.bottom = 320;
            }
            pTable.ColumnsTupleSize    = 60f;
            pTable.ColumnsTupleSpacing = 5f;

            // Only children scroll on X axis
            p.ScrollSensivityOnXAxis = 0f;

            // Scrollbar
            var sbTR = transform.Find("Scrollbar");

            if (sbTR)
            {
                p.Scrollbar = sbTR.GetComponent <Scrollbar>();
                OSAUtil.ConfigureDinamicallyCreatedScrollbar(p.Scrollbar, adapter, p.Viewport);
            }

            // Columns Scrollbar
            var csbTR = transform.Find("ColumnsScrollbar");

            if (csbTR)
            {
                pTable.ColumnsScrollbar = csbTR.GetComponent <Scrollbar>();
            }

            // Instantiate the tuple prefab & its value prefab
            pTable.TuplePrefab = InstantiateFromRes(paths.TUPLE_PREFAB, tuplePrefabsParent);
            var tupleAdapter = pTable.TuplePrefab.GetComponent(typeof(ITupleAdapter)) as ITupleAdapter;

            tupleAdapter.TupleParameters.ItemPrefab = InstantiateFromRes(paths.TUPLE_VALUE_PREFAB, tuplePrefabsParent);

            // Allowing resizing of individual tuples manually, by default
            tupleAdapter.TupleParameters.ResizingMode = TableResizingMode.MANUAL_TUPLES;

            // Instantiate the columns tuple prefab & its value prefab
            pTable.ColumnsTuplePrefab = InstantiateFromRes(paths.COLUMNS_TUPLE_PREFAB, columnsTuplePrefabsParent);
            var hTupleAdapter     = pTable.ColumnsTuplePrefab.GetComponent(typeof(ITupleAdapter)) as ITupleAdapter;
            var hTupleValuePrefab = hTupleAdapter.TupleParameters.ItemPrefab = InstantiateFromRes(paths.COLUMNS_TUPLE_VALUE_PREFAB, columnsTuplePrefabsParent);

            DisableLayoutComponentsInTupleValuePrefab(hTupleValuePrefab);

            // Assign the floating text input and dropdown
            pTable.FloatingDropdownPrefab    = Resources.Load <GameObject>(paths.INPUT__FLOATING_DROPDOWN).transform as RectTransform;
            pTable.TextInputControllerPrefab = Resources.Load <GameObject>(paths.INPUT__FLOATING_TEXT).GetComponent <TableViewTextInputController>();

            // Assign the options panel
            pTable.OptionsPanel = transform.Find("OptionsPanel") as RectTransform;

            Debug.Log("TableView instantiated. Resize mode was set to " + tupleAdapter.TupleParameters.ResizingMode +
                      ". If you don't plan to have individual rows resizeable, " +
                      "go over the tuple & column prefabs and their associated value prefabs and remove " +
                      "all Layout components, as they won't be needed. And set ResizeMode to NONE in inspector. " +
                      "This will boost scrolling performance.",
                      adapter.AsMonoBehaviour.gameObject
                      );
        }