コード例 #1
0
        public void DrawMarks(CommandBuffer commandBuffer, Marks marks, int screenX, int screenY)
        {
            var texture  = OpenTibiaUnity.GameManager.MarksViewTexture;
            var material = OpenTibiaUnity.GameManager.MarksViewMaterial;

            var position       = new Vector2(screenX, screenY);
            var scale          = new Vector2(Constants.FieldSize, Constants.FieldSize);
            var transformation = Matrix4x4.TRS(position, Quaternion.Euler(180, 0, 0), scale);

            var size = MarksStartSize;

            foreach (var information in _marksViewInformations)
            {
                if (!marks.IsMarkSet(information.MarkType))
                {
                    continue;
                }

                uint eightBit = marks.GetMarkColor(information.MarkType);
                if (eightBit > Marks.MarksNumTotal)
                {
                    continue;
                }

                Color color = GetMarksColor(eightBit);

                var uv = new Vector4()
                {
                    z = size * Constants.FieldSize / (float)texture.width,
                    w = (Constants.MarkThicknessBold - information.MarkThickness) * Constants.FieldSize / (float)texture.height,
                    x = Constants.FieldSize / (float)texture.width,
                    y = Constants.FieldSize / (float)texture.height,
                };

                var props = new MaterialPropertyBlock();
                props.SetTexture("_MainTex", texture);
                props.SetVector("_MainTex_ST", uv);
                props.SetColor("_Color", color);
                Utils.GraphicsUtility.Draw(commandBuffer, transformation, material, props);
            }
        }