示例#1
0
    private static void UpdatePreView(ref ImageTargetBehaviour marker)
    {
        if (Application.isPlaying)
        {
            return;
        }


        var mat = GetMarkerMaterial(Application.streamingAssetsPath + "/" + marker.GetPath());

        if (mat)
        {
            var render = marker.GetComponent <MeshRenderer>();
            if (render == null)
            {
                render = marker.gameObject.AddComponent <MeshRenderer>();
            }
            render.material = mat;
            float ratio      = (float)mat.mainTexture.height / (float)mat.mainTexture.width;
            var   meshFilter = marker.GetComponent <MeshFilter>();
            if (meshFilter == null)
            {
                meshFilter = marker.gameObject.AddComponent <MeshFilter>();
            }
            meshFilter.sharedMesh = makeQuadMesh(ratio);
        }
        EditorUtility.UnloadUnusedAssetsImmediate();
    }