*
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b6187ebbff88b841ba368983b0b6d05
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TextCore.Text;
|
||||
|
||||
public class MusicSheetRenderer : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
public FontAsset TextFont;
|
||||
public Material TextMaterial;
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public GameObject MakeGlyphObject(uint unicodeValue) {
|
||||
//0x1D11E
|
||||
|
||||
var glyphObject = new GameObject("Glyph_" + unicodeValue.ToString("X"));
|
||||
glyphObject.transform.localPosition = Vector3.zero;
|
||||
|
||||
var mr = glyphObject.AddComponent<MeshRenderer>();
|
||||
mr.sharedMaterial = TextMaterial;
|
||||
|
||||
var mf = glyphObject.AddComponent<MeshFilter>();
|
||||
var mesh = new Mesh();
|
||||
|
||||
var character = TextFont.characterLookupTable[unicodeValue];
|
||||
|
||||
var w = character.glyph.glyphRect.width;
|
||||
var h = character.glyph.glyphRect.height;
|
||||
|
||||
var maxHeight = TextFont.faceInfo.ascentLine - TextFont.faceInfo.descentLine;
|
||||
|
||||
var fw = (float)w / maxHeight;
|
||||
var fh = (float)h / maxHeight;
|
||||
|
||||
var vOffset = (character.glyph.metrics.horizontalBearingY - h) / maxHeight;
|
||||
|
||||
mesh.vertices = new Vector3[4]{
|
||||
new Vector3(0,0 + vOffset,0),
|
||||
new Vector3(0,fh+ vOffset,0),
|
||||
new Vector3(fw,fh+ vOffset,0),
|
||||
new Vector3(fw,0+ vOffset,0),
|
||||
};
|
||||
|
||||
mesh.triangles = new int[6] {
|
||||
0, 1, 2,
|
||||
0, 2, 3
|
||||
};
|
||||
|
||||
|
||||
Vector2 uvXY = new Vector2((float)character.glyph.glyphRect.x / TextFont.atlasWidth, (float)character.glyph.glyphRect.y / TextFont.atlasHeight);
|
||||
Vector2 uvWH = new Vector2((float)character.glyph.glyphRect.width / TextFont.atlasWidth, (float)character.glyph.glyphRect.height / TextFont.atlasHeight);
|
||||
|
||||
Vector2 uvMax = uvXY + uvWH;
|
||||
|
||||
//𝄞 1D11E
|
||||
mesh.uv = new Vector2[] {
|
||||
new Vector2 (uvXY.x, uvXY.y),
|
||||
new Vector2 (uvXY.x,uvMax.y),
|
||||
new Vector2 (uvMax.x,uvMax.y),
|
||||
new Vector2 (uvMax.x,uvXY.y),
|
||||
};
|
||||
|
||||
mf.sharedMesh = mesh;
|
||||
|
||||
return glyphObject;
|
||||
}
|
||||
|
||||
public static uint[] GetUtf32CodePoints(string text) {
|
||||
byte[] bytes = System.Text.Encoding.UTF32.GetBytes(text);
|
||||
uint[] result = new uint[bytes.Length / 4];
|
||||
Buffer.BlockCopy(bytes, 0, result, 0, bytes.Length);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void MakeString(string text) {
|
||||
var codePoints = GetUtf32CodePoints(text);
|
||||
|
||||
for(int i = 0; i < codePoints.Length; i++) {
|
||||
var glyph = MakeGlyphObject(codePoints[i]);
|
||||
glyph.transform.localPosition += new Vector3(i, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[CustomEditor(typeof(MusicSheetRenderer))]
|
||||
[CanEditMultipleObjects]
|
||||
public class LookAtPointEditor : Editor {
|
||||
SerializedProperty lookAtPoint;
|
||||
|
||||
void OnEnable() {
|
||||
|
||||
lookAtPoint = serializedObject.FindProperty("lookAtPoint");
|
||||
//UnityEngine.TextCore.LowLevel.FontEngine.LoadFontFace((target as MusicSheetRenderer).TextFont);
|
||||
|
||||
//obj.TextFont.
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
base.OnInspectorGUI();
|
||||
if(GUILayout.Button("Test font")) {
|
||||
var obj = (target as MusicSheetRenderer);
|
||||
obj.MakeString("𝄢𝄚𝄞𝄀𝄆𝅗𝅥");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41cd9c92ea5f6fe498720d63a7c054c2
|
||||
@@ -0,0 +1,157 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: New Material
|
||||
m_Shader: {fileID: 4800000, guid: 128e987d567d4e2c824d754223b3f3b0, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Cube:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _FaceTex:
|
||||
m_Texture: {fileID: 10300, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: -4727267763572039357, guid: 196cb11aaae922443abbac5d109fd3a0, type: 2}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OutlineTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Ambient: 0.5
|
||||
- _Bevel: 0.5
|
||||
- _BevelClamp: 0
|
||||
- _BevelOffset: 0
|
||||
- _BevelRoundness: 0
|
||||
- _BevelWidth: 0
|
||||
- _BumpFace: 0
|
||||
- _BumpOutline: 0
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _CullMode: 0
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _Diffuse: 0.5
|
||||
- _DstBlend: 0
|
||||
- _FaceDilate: 0
|
||||
- _FaceUVSpeedX: 0
|
||||
- _FaceUVSpeedY: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _GlowInner: 0.05
|
||||
- _GlowOffset: 0
|
||||
- _GlowOuter: 0.05
|
||||
- _GlowPower: 0.75
|
||||
- _GradientScale: 5
|
||||
- _LightAngle: 3.1416
|
||||
- _MaskSoftnessX: 0
|
||||
- _MaskSoftnessY: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineSoftness: 0
|
||||
- _OutlineUVSpeedX: 0
|
||||
- _OutlineUVSpeedY: 0
|
||||
- _OutlineWidth: 0
|
||||
- _Parallax: 0.02
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _Reflectivity: 10
|
||||
- _ScaleRatioA: 1
|
||||
- _ScaleRatioB: 1
|
||||
- _ScaleRatioC: 1
|
||||
- _ScaleX: 1
|
||||
- _ScaleY: 1
|
||||
- _ShaderFlags: 0
|
||||
- _Sharpness: 0
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SpecularPower: 2
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _TextureHeight: 512
|
||||
- _TextureWidth: 512
|
||||
- _UVSec: 0
|
||||
- _UnderlayDilate: 0
|
||||
- _UnderlayOffsetX: 0
|
||||
- _UnderlayOffsetY: 0
|
||||
- _UnderlaySoftness: 0
|
||||
- _VertexOffsetX: 0
|
||||
- _VertexOffsetY: 0
|
||||
- _WeightBold: 0.5
|
||||
- _WeightNormal: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
|
||||
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
|
||||
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cd77a6742e795f4191d877e8a5596ba
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user