예제 #1
0
    protected void CreateControls()
    {
        DestroyControls();

        /*
         * var debugJson = new JSONStorableString("Debug", Id);
         * RegisterStorable(debugJson);
         * var debugTextField = Script.CreateTextField(debugJson, true);
         * debugTextField.height = 80f;
         * var debugTextInputField = debugTextField.gameObject.AddComponent<UnityEngine.UI.InputField>();
         * debugTextInputField.textComponent = debugTextField.UItext;
         * debugJson.inputField = debugTextInputField;
         * RegisterControl(debugTextField);
         */

        if (IsDuplicate)
        {
            var jss = RegisterStorable(new JSONStorableString("Duplicate", "This item has duplicates and cannot be edited."));
            RegisterControl(Script.CreateTextField(jss));
        }
        else
        {
            _modifiedJson = new JSONStorableBool("This item has been modified", false);
            _modifiedJson.valNoCallback       = Modified;
            _modifiedJson.setCallbackFunction = (bool val) =>
            {
                if (val)
                {
                    // You cannot just enable the Modified flag without actually modifying anything
                    _modifiedJson.valNoCallback = false;
                    return;
                }

                ResetToInitial();
            };
            var resetUi = Script.CreateToggle(_modifiedJson, true);
            RegisterControl(resetUi);

            if (Mirror != null)
            {
                var goToMirrorButton = Script.CreateButton("Go to mirror", true);
                goToMirrorButton.button.onClick.AddListener(() =>
                {
                    Script.SendMessage("SelectEditable", Mirror);
                });
                RegisterControl(goToMirrorButton);
            }

            CreateControlsInternal();
        }
    }
예제 #2
0
        private SyncProxy TryConnectAtom(MVRScript storable)
        {
            if (storable == null)
            {
                return(null);
            }

            foreach (var l in _links.ToArray())
            {
                GetOrDispose(l);
            }

            var existing = _links.FirstOrDefault(a => a.storable == storable);

            if (existing != null)
            {
                return(existing);
            }

            var proxy = new SyncProxy
            {
                storable = storable
            };

            storable.SendMessage(nameof(IRemoteAtomPlugin.VamTimelineConnectController), proxy.dict, SendMessageOptions.RequireReceiver);

            if (!proxy.connected)
            {
                proxy.Dispose();
                return(null);
            }

            _links.Add(proxy);
            _links.Sort((s1, s2) => string.CompareOrdinal(s1.label, s2.label));

            _atomsJSON.displayChoices = _links.Select(l => l.label).ToList();
            _atomsJSON.choices        = _links.Select(l => l.storable.containingAtom.uid + "|" + l.storable.name).ToList();

            OnTimelineAnimationParametersChanged(storable);

            if (_selectedLink == null)
            {
                _selectedLink  = proxy;
                _atomsJSON.val = proxy.storable.containingAtom.uid + "|" + proxy.storable.name;
            }

            return(proxy);
        }