当前位置:网站首页>Unity 使用宏
Unity 使用宏
2022-07-25 23:01:00 【猫不在】
可以在player setting里面定义宏

也可以通过代码定义
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, item.Symbol);//将信息保存到宏信息里. 参数1:保存到哪个平台 参数2:要保存的内容.
官方解释
- 我以前一直以为定义一个符号之后,需要进行判断是否存在这个符号什么的。但是没有必要。

C#指令详细解释
使用来多渠道打包sdk
- 这个很好用的一点是可以来多渠道打包sdk
- 给不同的渠道定义不同的symbol
- 把和这些sdk相关的接入性质代码全部带上预编译指令
- 在自动化打包的时候,定义这些symbol,输出不同的包出来
- 但是我还有个问题,就是说,怎么把不同的文件区分出来。
- 就是说oppo需要依赖oppo.dll,华为需要依赖huawei.dll
- 怎么在打不同种类包的时候把这些文件给剔除掉。
[CreateAssetMenu(order =12,menuName ="创建渠道设定")]
public class ChannelSetting : ScriptableObject
{
public string Channel;
public string Symbol;
}
[MenuItem("Build/BuildAll")]
static void BuildAllPlatform()
{
var settings = Resources.LoadAll<ChannelSetting>("ChannelSettings");
foreach (var item in settings)
{
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, item.Symbol);//将信息保存到宏信息里. 参数1:保存到哪个平台 参数2:要保存的内容.
var path =Path.Combine( System.Environment.CurrentDirectory, item.Channel, $"{
item.Channel}.exe");
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
buildPlayerOptions.locationPathName = path;
buildPlayerOptions.target = BuildTarget.StandaloneWindows;
buildPlayerOptions.targetGroup = BuildTargetGroup.Standalone;
var res = BuildPipeline.BuildPlayer(buildPlayerOptions);
}
}
- 比较坑的一点是,打包时候需要指定输出文件夹,我一直以为是要指定文件夹,结果一直报错
UnityException: Build path contains project built with "Create Visual Studio Solution" option, which is incompatible with current build settings. Consider building your project into an empty directory. - 其实是还需要加上文件的名字
边栏推荐
- Notification(状态栏通知)详解
- 1000 okaleido tiger launched binance NFT, triggering a rush to buy
- JS makes elements get or lose focus
- ribbon 执行逻辑源码解析
- Shanghai Second Polytechnic University - Health Daily autocheck
- Zcmu--5015: complete the task
- Recyclerview computehorizontalscrollextend computehorizontalscrollrange computehorizontalscroll for calculating the sliding distance
- Tree view model example of QT
- Common software shortcuts
- 向下扎根,向上生长,探寻华为云AI的“根”力量
猜你喜欢

【MySQL提权】UDF提权(附带大马)

Review of static routing

Single model common sense reasoning first surpasses human beings! HFL summit openbookqa challenge

invalid syntax

Websocket summary

Mocha test
![[literature reading] - HRL -[hrl with universal policies for multi step robotic control]](/img/34/06d5ba3af4e6e775a335324c020161.png)
[literature reading] - HRL -[hrl with universal policies for multi step robotic control]

CMU AI PhD 第一年总结

Simple setting of drop-down triangle

Madness. Smbms (supermarket order management system)
随机推荐
Matrixcube unveils the complete distributed storage system matrixkv implemented in 102-300 lines
驱动板网线直连电脑共享网络配置
Node.js operation database
Qt的TQTreeWidget控件
Zcmu--5015: complete the task
Deploy flash based websites using Google cloud
Analysis of Excel file
第二周学习:卷积神经网络
Can generic types be used in array
Tree view model example of QT
ZCMU--5015: 完成任务
【论文笔记】A Meta-Reinforcement Learning Algorithm for Causal Discovery
如何获取广告服务流量变现数据,助力广告效果分析?
Network Security Learning (11) scanning and blasting
【MySQL提权】UDF提权(附带大马)
Ribbon execution logic source code analysis
Qt5.12 installation error prompt: c:\qt5.12.11\vcredist\vcredist_ msvc2019_ x86.exe /norestart /q
Tfrecord write and read
[tensorflow] about seed
Experiment 1, experiment 2 and Experiment 3 of assembly language and microcomputer principle: branch program design / loop program design / subroutine design