- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
假设您有一个适用于 iOS 的低级 Unity 插件,
所以在c#中
using System.Runtime.InteropServices;
using AOT;
public class Teste: MonoBehaviour {
[DllImport("__Internal")] private static extern
void set_texture_from_unity(System.IntPtr texture, int w, int h);
有一个纹理,.Apply()
它,然后将指针发送到原生 iOS 插件:
public void ClickPassTexture() {
tex = new Texture2D(256, 256, TextureFormat.ARGB32, false);
tex.filterMode = FilterMode.Point;
tex.Apply(); // ACTUALLY UPLOAD TO GPU
someMaterial.mainTexture = tex;
set_texture_from_unity(
tex.GetNativeTexturePtr(), tex.width, tex.height);
}
现在是 C 代码。
用几条彩色线条制作纹理,并将其写入Unity纹理。
#include <OpenGLES/ES2/gl.h>
...
void set_texture_from_unity(void *g_TextureHandle, int w, int h)) {
// make a texture with a few gray rows
unsigned char* data = malloc( g_TextureWidth * 4 * g_TextureHeight );
for (int i = 0; i < 1000; ++i) { data[i] = 100; }
// now, write that to the texture pointer given to us from Unity
GLuint gltex = (GLuint)(size_t)(g_TextureHandle);
glBindTexture(GL_TEXTURE_2D, gltex);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
g_TextureWidth, g_TextureHeight, GL_RGBA, GL_UNSIGNED_BYTE, data);
free(data);
因此,在 C 代码中,我们似乎已经成功地修改了纹理 tex
。
但是。
优秀的 Unity doco docs.unity3d.com/Manual/NativePluginInterface.html
给出了一个示例,其中 C 纹理更改被 Unity 渲染链中的回调调用。
但是。
我们什么时候想?
我认为这可能会奏效:
set_texture_from_unity( tex.GetNativeTexturePtr(),
tex.width, tex.height);
// the plugin has changed the texture...
// perhaps an Apply will change it on screen?!
tex.Apply();
但是不行! (如果您在 .Apply
之前等待几帧,这没有什么区别。)
你会认为 .Apply
会再次将纹理发送到 gpu,但它似乎不起作用。
简而言之,在 C 插件运行后,如何处理呈现的代码,使其“立即”显示新纹理??
当你知道一个 Texture 已经被 C 插件修改时,在 iOS 上,如何让 Unity 显示更改???
最佳答案
来自 Unity Japan 的(传奇)Keijiro Takahashi 发布了可能是 Unity 发布的最重要的内容:
https://github.com/keijiro/TextureUpdateExample
(新)来自插件的逐帧样式纹理更新的实际示例。
它适用于 IOS
再次强调,这几乎是 Unity 发出的最有值(value)的东西!呸!
关于提出的问题,我真的从来没有找到解决方案。
关于c# - 您可以从 iOS C 插件 "on the spot"写入 Unity 纹理吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54189957/
这是关于最近的公告: https://aws.amazon.com/about-aws/whats-new/2020/01/amazon-ec2-spot-instances-stopped-star
基于这篇文章,计划使用 EC2 Spot 实例/队列作为我们的 jenkins 从站解决方案 https://jenkins.io/blog/2016/06/10/save-costs-with-ec
最近,Amazon AWS 发布了适用于 Spot 队列的 Auto Scaling (https://aws.amazon.com/blogs/aws/new-auto-scaling-for-ec
我正在编写代码以使用此页面中的文档跟踪现场请求:http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances-bid-
我正在寻找一种以编程方式在列表中查找可用(未使用)位置的方法,通常是一组条件。我可以给你一个电话簿的例子:我将生成具有特定规则的电话号码(例如,在本例中为 7 位数字,这非常简单)。 “生成器”将随机
我正在尝试使用 Android 手机实现点测光。 parameters.set("自动曝光", "点测光"); 但是,我对计量的工作原理有点困惑。如果我理解正确的话,点测光的工作原理是选择一个用于设置
亚马逊公布中断频率here . VM中断了多长时间?是否有可用的数字(平均中断时间,...)? 最佳答案 您分享的链接包含您正在寻找的信息 The average frequency of inter
我正在尝试使用 python-sdk 在 Azure 云上创建一个 Spot 实例,我按照文档设置了优先级、计费配置文件和 eviction_policy ,但是当我检查控制台时,它给出了 Azure
已关闭。这个问题是 not about programming or software development 。目前不接受答案。 这个问题似乎不是关于 a specific programming
首先,我想澄清一下,我是 AWS 的新手,尤其是 Spot 实例,所以请原谅我缺乏特定的语言。 我必须实现以下设置: 每 8 小时创建一个 spot 实例 每次运行一个R脚本(运行大约需要35分钟)
首先,我想澄清一下,我是 AWS 的新手,尤其是 Spot 实例,所以请原谅我缺乏特定的语言。 我必须实现以下设置: 每 8 小时创建一个 spot 实例 每次运行一个R脚本(运行大约需要35分钟)
我计划开始使用 Amazon EC2,并且和所有人一样,我想使用 Spot 实例。 将用于迷你游戏服务器,因此 Spot 实例非常适合于此。玩家进入,进行比赛和离开,因此当Spot实例因Spot实例价
我尝试登录这些网站: https://www.epexspot.com/en/extras/EPEXme/login使用 Python 的 requests 方法。我尝试了以下代码,但由于我对此很陌生
我需要在 Ubuntu 上安装 Apache Spot。 http://spot.incubator.apache.org/doc/#installation 我已经按照本指南完成了 Hadoop 单
在游戏 Dobble ("Spot it") 中,有一副 57 张纸牌,每张纸牌上有 8 个不同的符号。该系统是随机选择的任意两张牌将只有一个匹配的符号。这促使我了解系统背后的数学背景,因此我编写了一
我正在尝试了解如何使用 spot 实例的终止时间。来自这篇文章https://aws.amazon.com/blogs/aws/new-ec2-spot-instance-termination-no
我正在尝试使用新的 Managed Spot Training 功能从现有模型开始训练对象检测模型,创建 Estimator 时使用的参数如下: od_model = sagemaker.estima
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我正在开发 Cassandra 数据模型来存储用户上传的记录。 潜在的问题是,某些用户可能在 5 分钟内上传 50-100k 行,这可能会导致分区键 (user_id) 出现“热点”。 (如果每个分区
我刚刚开始使用 QuantLib 并了解各种功能。问题是我有一个假设的现货曲线,如下所示 spot_tenors = [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5、
我是一名优秀的程序员,十分优秀!