protected override void FreeManaged()
        {
            foreach (var handle in Handles)
            {
                handle.Dispose();
            }

            Handles.Clear();
            MessageQueue.Clear();

            base.FreeManaged();
        }
Beispiel #2
0
        public async Task OnShutdown()
        {
            Functions.Clear();

            foreach (var handle in Handles)
            {
                handle.Free();
            }

            Handles.Clear();

            await Task.CompletedTask;
        }
Beispiel #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                // if (disposing) { /* dispose managed resources */ }

                foreach (var handle in Handles)
                {
                    CloseHandleFunction(handle);
                }
                Handles.Clear();
            }
            IsDisposed = true;
        }
Beispiel #4
0
        private void Refresh()
        {
            if (!preventAutoGUI)
            {
                Clear();

                if (Localizer.Instance == null)
                {
                    Add(new Label("Localizer is not loaded. Try refresh."));
                    return;
                }
            }

            foreach (var handle in Handles)
            {
                handle.Dispose();
            }

            Handles.Clear();
            UnaddedPacks.Clear();

            if (!string.IsNullOrEmpty(UnitPath) && !string.IsNullOrEmpty(Key))
            {
                foreach (var pack in Localizer.Instance.Packs)
                {
                    var handle = pack.RequestUnitHandle(UnitPath);
                    if (!handle.IsEmpty())
                    {
                        if (handle.TryGetText(Key, out string value))
                        {
                            Handles.Add(handle);
                            continue;
                        }
                    }

                    UnaddedPacks.Add(pack);
                    handle.Dispose();
                }
            }

            if (!preventAutoGUI)
            {
                ImguiContainer = new IMGUIContainer(() =>
                {
                    var r    = this.ImguiContainer.contentRect;
                    r.width -= 20f;
                    r.x     += 20f;
                    OnGUI(r);
                    this.ImguiContainer.style.height = GetPropertyHeight();
                });
                Add(ImguiContainer);
            }

            return;

            //以下、UIElements用コード

            /*
             *
             * var visualTree =
             *  AssetDatabase.LoadAssetAtPath(
             *      "Assets/Ruccho/ORLL/Unity/Scripts/Editor/LocalizedTextField/LocalizedTextField.uxml",
             *      typeof(VisualTreeAsset)) as VisualTreeAsset;
             * VisualElement uxml = visualTree.CloneTree();
             * this.Add(uxml);
             *
             * foreach (var handle in Handles)
             * {
             *  AddLocalizationElement(handle, Key);
             * }
             *
             *
             * refreshButton = this.Q<Button>("refresh");
             * refreshButton.clickable.clickedWithEventInfo += RefreshButton_Clicked;
             *
             * var addButton = this.Q<Button>("add");
             * var m = new ContextualMenuManipulator((e) =>
             * {
             *  if (!string.IsNullOrEmpty(UnitPath) && !string.IsNullOrEmpty(Key))
             *      foreach (var pack in Localizer.Instance.Packs)
             *      {
             *          var handle = pack.RequestUnitHandle(UnitPath);
             *          if (!handle.IsEmpty())
             *          {
             *              if (handle.TryGetText(Key, out string value))
             *              {
             *                  handle.Dispose();
             *                  continue;
             *              }
             *          }
             *
             *          handle.Dispose();
             *          e.menu.AppendAction($"{pack.Name} ({pack.Guid})", a =>
             *              {
             *                  pack.RequestUnitHandle(UnitPath, true).AddKey(Key);
             *
             *                  Refresh();
             *              },
             *              a => DropdownMenuAction.AlwaysEnabled(a));
             *      }
             * });
             * m.target = addButton;
             * m.activators.Clear();
             *
             * m.activators.Add(new ManipulatorActivationFilter() {button = MouseButton.LeftMouse, clickCount = 1});
             */
        }