unity怎么创建空物体smcs.rsp

通过Unity预编译文件smcs.rsp文件添加预编译命令 - 简书
通过Unity预编译文件smcs.rsp文件添加预编译命令
可以在Unity Assets目录下创建smcs.rsp文件,并向其中添加预编译命令,其会在unity启动时执行,比如新建一个smcs.rsp文件,向其中添加内容:-define:MYDEF然后就可以在脚本中加入宏判断:
#endif其原理是启动Unity时会执行unity目录下的smcs.exe文件并添加预编译命令,也可以通过cmd运行smcs.exe逐个添加预编译命令。另外还有可以创建gmcs.rsp文件,对应Editor脚本中的预编译命令。详细:
Custom Preprocessor Directives
It is also possible to define your own preprocessor directives to control which code gets included when compiling. To do this you must add in the "Assets/" folder a text file with the extra directives. The name of the file depends on the language you are using :
&Project Path&/Assets/smcs.rsp
C# - Editor Scripts
&Project Path&/Assets/gmcs.rsp
UnityScript
&Project Path&/Assets/us.rsp
&Project Path&/Assets/boo.rsp
As an example, if you include the single line '-define:UNITY_DEBUG' in your smcs.rsp file the define UNITY_DEBUG will exist as a global define for C# scripts, except for Editor scripts.Every time you make make changes to the .rsp files a recompilation needs to be done for them to be effective. You can do this by updating or reimporting a single script (.js, .cs or .boo) file.The usage of the .rsp files is described in the help of the smcs application, included in the Editor installation folder. You can get more information by running : "smcs -help".
比如如果想要在C#语言中使用指针,必须标记为unsafe的,默认情况下unity中使用unsafe标记会报错,可以在项目中添加smcs.rsp文件并加入-unsafe预编译命令,就可以编译通过。1535人阅读
Unity3D(23)
前两篇讲解了如何使用导入NuGet程序包和动态链接库的方式来使用Protobuf-net。接下来将讲解如何直接在Unity中使用源码来进行序列化与反序列化操作。
首先需要获取源码,获取方式上一篇已经说明,不清楚的可以看:
创建一个Unity工程,然后将源码中的“protobuf-net”文件夹导入到Unity工程中,“protobuf-net”文件夹是“protobuf-net”的工程目录,包含了其所有的需要用到的源码。等待Unity编译完成。
经过Unity编译后会报不安全代码的错误,是因为使用了指针,则需要在Assets目录下添加一个“smcs.rsp”文件,用于控制smcs的脚本编译。
在“smcs.rsp”中添加如下内容:
-define:FEAT_COMPILER;PLAT_BINARYFORMATTER;PLAT_XMLSERIALIZER;PLAT_NO_INTERLOCKED;FEAT_SAFE
-unsafe 表示允许不安全代码;
-define 定义宏,用于控制需要编译的代码。因为是在Unity中使用,就按如上定义。不清楚如何定义的可以看“protobuf-net”工程目录下的“protobuf-net.csproj”文件,如下:
如果还想添加其他命令,可以通过以下方式查看:
& Unity安装目录 & \Editor\Data\Mono\lib\mono\unity\smcs.exe -help
“smcs.rsp”文件修改保存后,必须需要重新编译文件,可以将其Reimport。此时,不安全代码的错误就没有了。
至此Protobuf-net导入Unity工程成功,接下来讲解如何使用。
使用的方法与中的是用方式是一样的。
需要序列化与反序列化的对象,可以手动定义,也可以通过“ *.proto“文件来生成。通过文件生成的方法中已经讲解,不清楚的可以去看看protogen是怎么使用的,在此就不赘述。
在摄像机上附加一个脚本,并添加如下代码:
using UnityE
using System.C
using System.IO;
[ProtoBuf.ProtoContract]
class Person
[ProtoBuf.ProtoMember(1)]
public string
[ProtoBuf.ProtoMember(2)]
public int
public class test : MonoBehaviour
void Start()
Person per = new Person();
per.age = 1;
per.name = "xiangmu";
using (Stream s = File.OpenWrite("test.dat"))
ProtoBuf.Serializer.Serialize&Person&(s, per);
Person per2 = null;
using (Stream s = File.OpenRead("test.dat"))
per2 = ProtoBuf.Serializer.Deserialize&Person&(s);
print("name&" + per2.name + " age&" + per2.age);
Protobuf-net的简单使用就这些,如果后续有高级用法,本人会继续更新。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:20049次
排名:千里之外
原创:43篇
评论:17条
(1)(1)(1)(3)(5)(1)(3)(8)(6)(2)(1)(9)(1)(1)当前位置:
微信扫一扫分享到朋友圈
unity PSD Importer is an add-on forUnity3d. It provides an editor window from which individual layers can beselected and exported. The layers are exported either as individual PNGs or asan atlas image.
Unity PSD Importer是unity3d的一款插件。它提供了一个编辑器窗口,可以选择和输出单独的图层。输出的图层可以作为单独的PNG格式文件或者是图集。
To compile the Unity PSD Importer in the Unity3D Editoryou must have the files gmcs.rsp and smcs.rsp with &-unsafe& in thefirst line of the files in the root directory of your project. Otherwise youcan compile the code as a DLL and it will also work in the editor.
要在Unity3D编辑器中编译Unity PSD Importer插件,必须在你的项目的根目录下放置gmcs.rsp和smcs.rsp两个文件,并在两个文件的第一行添加“_unsafe”。或者你可以将代码编译成一个DLL,这样也可以在编辑器中使用。
To use the Unity PSD Importer, in the Unity3D Editor goto Sprites & PSD Import to access the importer, then drag and drop or searchfor the PSD file you wish to import.
要使用Unity PSD Importer,具体操作是:在Unity3D编辑器中选择Sprite → PSD Import to access the importer,然后拖拽,或者找到你想要的PSD文件,将它们导入。
To only export the layers to PNG files, click on the &ExportVisible Layers& button and it will only create the PNG files with thesprites that are visible. You can individually check which layers you want toimport.
如果想要将图层输出为PNG格式文件,点击“ExportVisible Layers”按钮,那么它就会仅将可见的sprites(子图形)输出,创建成PNG文件。你也可以单独检测,您想要导入的图层。
To create a root gameobject with all the layers as childsprites and the layers compiled in an atlas, click on the &Createatlas& button. All the layers will be saved to an atlas texture withsprites as children that is auto generated with the atlas size you define under&Max. atlas size&. A root gameobject with the filename of the PSDfile is created and all the layers as sprites will be as children gameobjectsunder the root gameobject.
如果想要创建一个,将所有图层变成子图形,并且将图层合并成图集的根目录游戏物体时,点击“Create atlas”按钮。所有的图层将保存到一个图集texture文件中,并且子图形将自动变换为你已经设定的尺寸。此时,根目录下将会创建一个与PSD文件同名的游戏物体,并且PSD文件的所有图层,将作为子物体中的子图层,存在于根目录的游戏物体之下。
To create PNG files individually with each spriteassigned to the PNG files, click on the &Create sprites& button. Thiswill create a root gameobject with the filename of the PSD file and all thelayers as sprites under the root gameobject.
如果想要将PNG文件里面的每个子图形,一个个单独输出,点击“Create sprites”按钮。这时,将会在根目录下创建一个与PSD文件同名的游戏物体,然后所有的图层将变成位于根物体下的独立子图形。
All sprites are created with a center pivot so that theywill import in their correct alignment with the PSD file layers' positions.
所有子图形都会创建一个中心旋转枢轴。这样,他们在导入时,会按照PSD文件图层的所在位置正确对齐。
Some notes on the PSD support:
一些关于PSD支持的备注:
It should support all image layers, however text, layergroups, or other special layers will not be supported. It is best to flattenlayer groups and text before importing.
它目前能够支持所有图像图层。然而文本、图层组,或者其他特殊的图层,无法支持。所以最好在使用之前,先将图层组和文字弄平,再导入。
All the imported layers should be imported at their samepositions as in the PSD file.
所有导入的图层,必须保持它们在PSD文件中的相同位置。
Whenimporting as an atlas, if the layers cannot collectively fit in the atlas theywill be scaled down to fit the atlas texture, therefore it is preferable toimport the layers using &Create sprites& to have the layers importedas separate PNG files.
当导入图集时,如果图层不能正常满足图集的尺寸大小,则将被缩减至合适的图集尺寸大小。因此,导入图层时,最好使用“Createsprites”将各个图层,导入成单独的PNG格式文件。原文:/Banbury/UnityPsdImporter译文:蛮牛译馆 - pikachu 和 OVATION转载注明出处!!!
我是游戏蛮牛的蛮牛译馆(一个专门翻译国外资料的组织)的一员,我会陆续整理,翻译国外unity相关的新闻资讯与技术文章,以及各种视频等内容。我们也欢迎热爱游戏翻译的好友加群,一起体验翻译并分享乐趣,QQ群号:。关于此篇文章翻译有错误的地方,欢迎大家指正。
蛮牛译馆期待您的加入:/thread-.html
分享给好友
分享到微信朋友圈:
第一步 打开微信底部扫一扫
第二步 扫下面的文章二维码
第三步 右上角点击转发
相关文章Relevant
■ 点击上面蓝字一键关注 ▲QIBU生活微刊建议在WIFI下观看,土豪请随意~~1、每一次接吻 会消耗体内至少12个卡路里科学家指出:...
我是主播 贝妮~(微信号:Voaoao)每天提供最热门、最火爆、最精彩的视频!口味有点儿重喔~笑死!笑死!笑死!如果觉得这些还...
【最费脑力的14部电影】《盗梦空间》、《记忆裂痕》、《生死停留》、《死亡幻觉》、《禁闭岛》、《穆赫兰道》、《蝴蝶效应》、...
现如今,飞机以舒适、方便与节省时间等原因成为出行首选的交通方式之一.可你是否知道,为何不能喝飞机上的冲泡茶饮,又为何在...
感知CG,感触创意,感受艺术,感悟心灵 在CG世界的一期中我们展示了 Vince Low的一部分作品,今天再次翻看CG网站时发现他的...
因女儿未出世便患肿瘤,柴静离职后首发雾霾调查.雾霾是什么?它从哪儿来?我们怎么办?看完这些,才知道雾霾的真相.震撼!震...不怨天,不尤人,下学而上达,知我者其天乎!
Maya导出动画到Unity
一、创建动画
(1) 随便拖个物体到Maya编辑器
(2) 【显示】|【UI元素】|【时间滑块】 显示出动画时间线
(3) 插入几个关键帧动画
(4) 选中要导出的动画物件
(5) 【编辑】|【关键帧】|【烘焙模拟】对动画进行烘焙 (只有经烘焙后的动画(FBX)在Unity中才能播放)
(6) 【文件】|【导出当前选择】 &保存为FBX格式,然后再把这个FBX文件导入到Unity
(7) 选中gueng2.fbx,设置动画类型为Legacy
(8) 设置动画为循环播放
(9) 在Unity中播放测试。
Flash游戏设计:
Unity游戏设计:Unity3D, VR, AR, Architecture, 3D, 3DSMax
on Nov.28, 2011, under ,
I had to integrate a small set of third party code that calls down to some win32 dllimport bits, to do this I needed to be able to work with some pointers. which in c# need to be declared in an unsafe function, so that it knows to be unmanaged.
Slightly awkward, but it turns out that there is an -unsafe compiler option that needs to be turned on in unity/mono, and that you can do this very easily on a per project basis by adding a file ‘smcs.rsp’ to the root of your assets dir, and in there you can add the text ‘-unsafe’ to add this to the compiler commandline.
Reference threads: , ,
Other apparent uses stated in the threads are setting project wide defines and pragmas
Leave a Reply
BlogrollA few highly recommended websites...
ArchivesAll entries, chronologically...}

我要回帖

更多关于 unity smcs.rsp 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信