protected override void Awake()
 {
     base.Awake();
     _rebuildData = GetComponent <RebuildData>();
     _vertex3     = new UIVertex();
     _vertex2     = new UIVertex();
     _vertex1     = new UIVertex();
 }
        //================================================================================
        // 関数
        //================================================================================
        /// <summary>
        /// リビルドされた UI を確認して返します
        /// </summary>
        public static List <RebuildData> Check()
        {
            var rebuildList = new List <RebuildData>();

            for (var i = 0; i < GraphicRebuildQueue.Count; i++)
            {
                var canvasElement = GraphicRebuildQueue[i];

                // 破棄済みのゲームオブジェクトにアクセスしてしまうことがあるため
                // null チェックしています
                if (canvasElement == null)
                {
                    continue;
                }

                var graphic = canvasElement as Graphic;

                if (graphic == null)
                {
                    continue;
                }

                var canvas = graphic.canvas;

                if (canvas == null)
                {
                    continue;
                }

                var rebuildTargets = canvas
                                     .GetComponentsInChildren <Transform>(true)
                                     .Select(x => x.gameObject)
                                     .ToArray()
                ;

                var rebuildData = new RebuildData
                                  (
                    graphic: graphic,
                    canvas: canvas,
                    rebuildTargets: rebuildTargets
                                  );

                rebuildList.Add(rebuildData);
            }

            return(rebuildList);
        }
 public void RebuildVisibleList()
 {
     try
     {
         nextRebuildingData = currentRebuildData;
         rebuildSemaphore.Release();
     }
     catch
     {
     }
 }
        void RebuildVisibleCallback()
        {
            if (currentEditor.InvokeRequired)
            {
                currentEditor.Invoke(new RebuildCallbackDelegate(RebuildVisibleCallback));
                return;
            }

            currentRebuildData = rebuildingData;

            Point p = currentEditor.GetPixelAtTextpoint(currentEditor.caret.Position, false);
            p = currentEditor.PointToScreen(p);
            int desiredRows = Math.Max(1, Math.Min(10, currentRebuildData.displayedItems.Count));
            Size size = new Size(0, desiredRows * Font.Height);
            if (SelectedIndex < LineOffset || SelectedIndex + 10 >= LineOffset)
                LineOffset = SelectedIndex;

            var enumerator = currentRebuildData.displayedItems.GetEnumerator(LineOffset);
            Graphics g = Graphics.FromImage(new Bitmap(1, 1));
            while (enumerator.MoveNext())
            {
                size.Width = Math.Max(size.Width,
                                        (int)g.MeasureString(enumerator.Current.DisplayText, Font).Width);
            }
            size.Width += 16;
            ParentForm.UpdateAndShow(p, ref size);
            Invalidate();
            Point pos = currentEditor.GetPixelAtTextpoint(currentEditor.caret.GetPosition(true));
            if (ParentForm.Visible)
                pos.X += size.Width;

            currentEditor.ime.SetIMEWindowLocation(pos.X, pos.Y);
            SelectedIndex = SelectedIndex;
        }
        void RebuildThread()
        {
            while (!Form1.Form.F_Disposed)
            {
                try
                {
                    while (!rebuildSemaphore.WaitOne(5000))
                    {
                        if (Form1.Form.F_Disposed) return;
                    }
                    if (Form1.Form.F_Disposed) return;
                    while (nextRebuildingData != null)
                    {
                        rebuildingData = nextRebuildingData;
                        nextRebuildingData = null;
                        RebuildVisibleListInternal();
                        if (Form1.Form.F_Disposed) return;
                    }
                    RebuildVisibleCallback();

                }
                catch (Exception err)
                {
                    Program.ErrorHandeler(this, new ThreadExceptionEventArgs(err));
                }
            }
        }
示例#6
0
        public unsafe EmitResult Emit(
            Stream rebuildPeStream,
            Stream?rebuildPdbStream,
            Compilation rebuildCompilation,
            ImmutableArray <EmbeddedText> embeddedTexts,
            CancellationToken cancellationToken)
        {
            var peHeader       = OptionsReader.PeReader.PEHeaders.PEHeader !;
            var win32Resources = OptionsReader.PeReader.GetSectionData(peHeader.ResourceTableDirectory.RelativeVirtualAddress);

            using var win32ResourceStream = win32Resources.Pointer != null
                ? new UnmanagedMemoryStream(win32Resources.Pointer, win32Resources.Length)
                : null;

            var sourceLink = OptionsReader.GetSourceLinkUtf8();

            var    debugEntryPoint = getDebugEntryPoint();
            string?pdbFilePath;
            DebugInformationFormat debugInformationFormat;

            if (OptionsReader.HasEmbeddedPdb)
            {
                if (rebuildPdbStream is object)
                {
                    throw new ArgumentException(RebuildResources.PDB_stream_must_be_null_because_the_compilation_has_an_embedded_PDB, nameof(rebuildPdbStream));
                }

                debugInformationFormat = DebugInformationFormat.Embedded;
                pdbFilePath            = null;
            }
            else
            {
                if (rebuildPdbStream is null)
                {
                    throw new ArgumentException(RebuildResources.A_non_null_PDB_stream_must_be_provided_because_the_compilation_does_not_have_an_embedded_PDB, nameof(rebuildPdbStream));
                }

                debugInformationFormat = DebugInformationFormat.PortablePdb;
                var codeViewEntry = OptionsReader.PeReader.ReadDebugDirectory().Single(entry => entry.Type == DebugDirectoryEntryType.CodeView);
                var codeView      = OptionsReader.PeReader.ReadCodeViewDebugDirectoryData(codeViewEntry);
                pdbFilePath = codeView.Path ?? throw new InvalidOperationException(RebuildResources.Could_not_get_PDB_file_path);
            }

            var rebuildData = new RebuildData(
                OptionsReader.GetMetadataCompilationOptionsBlobReader(),
                getNonSourceFileDocumentNames(OptionsReader.PdbReader, OptionsReader.GetSourceFileCount()));
            var emitResult = rebuildCompilation.Emit(
                peStream: rebuildPeStream,
                pdbStream: rebuildPdbStream,
                xmlDocumentationStream: null,
                win32Resources: win32ResourceStream,
                manifestResources: OptionsReader.GetManifestResources(),
                options: new EmitOptions(
                    debugInformationFormat: debugInformationFormat,
                    pdbFilePath: pdbFilePath,
                    highEntropyVirtualAddressSpace: (peHeader.DllCharacteristics & DllCharacteristics.HighEntropyVirtualAddressSpace) != 0,
                    subsystemVersion: SubsystemVersion.Create(peHeader.MajorSubsystemVersion, peHeader.MinorSubsystemVersion)),
                debugEntryPoint: debugEntryPoint,
                metadataPEStream: null,
                rebuildData: rebuildData,
                sourceLinkStream: sourceLink != null ? new MemoryStream(sourceLink) : null,
                embeddedTexts: embeddedTexts,
                cancellationToken: cancellationToken);

            return(emitResult);
    protected override void OnPopulateMesh(VertexHelper toFill)
    {
        base.OnPopulateMesh(toFill);
        if (type != Type.Filled || fillOrigin != 0 || fillMethod != FillMethod.Horizontal)
        {
            return;
        }
        if (!_rebuildData)
        {
            _rebuildData = GetComponent <RebuildData>();
        }
        if (toFill.currentIndexCount <= 3)
        {
            return;
        }
        toFill.PopulateUIVertex(ref _vertex3, 3);
        toFill.PopulateUIVertex(ref _vertex2, 2);
        toFill.PopulateUIVertex(ref _vertex1, 1);

        float inputAdjustX = _rebuildData.VertexAdjustDatas[0].PosAdjust.x;
        float inputAdjusty = _rebuildData.VertexAdjustDatas[0].PosAdjust.y;

        float length   = Mathf.Abs(_vertex1.position.x - _vertex3.position.x);
        float height   = Mathf.Abs(_vertex1.position.y - _vertex3.position.y);
        float percentl = inputAdjustX / length;
        float percenth = inputAdjusty / height;
        float uvlength = Mathf.Abs(_vertex1.uv0.x - _vertex3.uv0.x);
        float uvHeight = Mathf.Abs(_vertex1.uv0.y - _vertex3.uv0.y);
        float uChange  = percentl * uvlength;
        float vChange  = percenth * uvHeight;

        _vertex2.position.x = _vertex2.position.x - inputAdjustX;
        _vertex2.uv0.x      = _vertex2.uv0.x - uChange;
        toFill.SetUIVertex(_vertex2, 2);

        _vertex3.position.x = _vertex3.position.x - inputAdjustX;
        _vertex3.uv0.x      = _vertex3.uv0.x - uChange;
        toFill.SetUIVertex(_vertex3, 3);

        float adjX     = inputAdjusty * inputAdjustX / (height - inputAdjusty);
        float percent2 = adjX / length;
        float uChange2 = percent2 * uvlength;

        if (_rebuildData.tiltLeft)
        {
            _vertex3.position.x = _vertex3.position.x + inputAdjustX;
            _vertex3.uv0.x      = _vertex3.uv0.x + uChange;
            toFill.AddVert(_vertex3);

            _vertex3.position.y = _vertex3.position.y + inputAdjusty;
            _vertex3.uv0.y      = _vertex3.uv0.y + vChange;
            toFill.AddVert(_vertex3);

            _vertex3.position.y = _vertex3.position.y - inputAdjusty;
            _vertex3.position.x = _vertex3.position.x + adjX;
            _vertex3.uv0.x      = _vertex3.uv0.x + uChange2;
            _vertex3.uv0.y      = _vertex3.uv0.y - vChange;
            toFill.AddVert(_vertex3);

            toFill.AddTriangle(3, 2, 4);
            toFill.AddTriangle(4, 2, 5);
            toFill.AddTriangle(4, 5, 6);
        }
        else
        {
            _vertex2.position.x = _vertex2.position.x + inputAdjustX;
            _vertex2.uv0.x      = _vertex2.uv0.x + uChange;
            toFill.AddVert(_vertex2);

            _vertex2.position.y = _vertex2.position.y - inputAdjusty;
            _vertex2.uv0.y      = _vertex2.uv0.y - vChange;
            toFill.AddVert(_vertex2);

            _vertex2.position.y = _vertex2.position.y + inputAdjusty;
            _vertex2.position.x = _vertex2.position.x + adjX;
            _vertex2.uv0.x      = _vertex2.uv0.x + uChange2;
            _vertex2.uv0.y      = _vertex2.uv0.y + vChange;
            toFill.AddVert(_vertex2);

            toFill.AddTriangle(3, 2, 4);
            toFill.AddTriangle(5, 3, 4);
            toFill.AddTriangle(5, 4, 6);
        }
    }