Esempio n. 1
0
        private void InitCustomUI()
        {
            var atomsToLinkUI = CreateScrollablePopup(_atomsToLink);

            atomsToLinkUI.popupPanelHeight           = 800f;
            atomsToLinkUI.popup.onOpenPopupHandlers += () => _atomsToLink.choices = GetAtomsWithVamTimelinePlugin().ToList();

            _linkButton = CreateButton("Link");
            _linkButton.button.interactable = _atomsToLink.choices.Count > 0;
            _linkButton.button.onClick.AddListener(() => LinkAtom(_atomsToLink.val));

            var resyncButton = CreateButton("Re-Sync Atom Plugins");

            resyncButton.button.onClick.AddListener(() =>
            {
                DestroyControlPanelContainer();
                _mainLinkedAnimation = null;
                RestoreAtomsLink(_savedAtomsJSON.val);
                _atomsToLink.choices = GetAtomsWithVamTimelinePlugin().ToList();
            });

            CreateToggle(_autoPlayJSON, true);

            CreateToggle(_hideJSON, true);

            CreateToggle(_enableKeyboardShortcuts, true);
        }
Esempio n. 2
0
        private void LinkAtom(string uid)
        {
            try
            {
                if (uid.IndexOf(_atomSeparator) > -1)
                {
                    SuperController.LogError($"VamTimeline: Atom '{uid}' cannot contain '{_atomSeparator}'.");
                    return;
                }
                if (_linkedAnimations.Any(la => la.atom.uid == uid))
                {
                    return;
                }

                var atom = SuperController.singleton.GetAtomByUid(uid);
                if (atom == null)
                {
                    SuperController.LogError($"VamTimeline: Atom '{uid}' cannot be found. Re-link the atom to fix.");
                    return;
                }

                var link = LinkedAnimation.TryCreate(atom);
                if (link == null)
                {
                    SuperController.LogError($"VamTimeline: Atom '{uid}' did not have the Timeline plugin. Add the plugin and re-link the atom to fix.");
                    return;
                }
                _linkedAnimations.Add(link);
                _atomsJSON.choices = _linkedAnimations.Select(la => la.label).ToList();
                if (_mainLinkedAnimation == null)
                {
                    SelectCurrentAtom(link.label);
                }
                _savedAtomsJSON.val  = string.Join(_atomSeparator, _linkedAnimations.Select(la => la.atom.uid).Distinct().ToArray());
                _atomsToLink.choices = GetAtomsWithVamTimelinePlugin().ToList();
                _atomsToLink.val     = _atomsToLink.choices.FirstOrDefault() ?? "";
            }
            catch (Exception exc)
            {
                SuperController.LogError($"VamTimeline.{nameof(ControllerPlugin)}.{nameof(LinkAtom)}: " + exc);
            }
        }
Esempio n. 3
0
        private void SelectCurrentAtom(string label)
        {
            if (string.IsNullOrEmpty(label))
            {
                _mainLinkedAnimation = null;
                return;
            }
            var mainLinkedAnimation = _linkedAnimations.FirstOrDefault(la => la.label == label);

            if (_mainLinkedAnimation == mainLinkedAnimation)
            {
                return;
            }
            _mainLinkedAnimation = mainLinkedAnimation;
            if (_mainLinkedAnimation == null)
            {
                return;
            }
            _atomsJSON.valNoCallback = _mainLinkedAnimation.label;
            StartCoroutine(InitializeMainAtom(_mainLinkedAnimation.atom.uid));
        }