当前位置:网站首页>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. - 其实是还需要加上文件的名字
边栏推荐
- [PTA] 7-19 check face value (15 points)
- Simple setting of drop-down triangle
- Recyclerview computehorizontalscrollextend computehorizontalscrollrange computehorizontalscroll for calculating the sliding distance
- Qt的TQTreeWidget控件
- ribbon 执行逻辑源码解析
- Vs2017 compilation encountered the error HResult e returned by the call of COM component_ FAIL
- CSV intro
- HCIE终到手,路才开始
- Simple setting method of search box
- Analysis of Excel file
猜你喜欢

Network Security Learning (XIII) data link layer

IPFs of Internet Protocol

Sichuan cuisine menu (I)
![[paper notes] a meta reinforcement learning algorithm for causal discovery](/img/03/84462b38551c41173f7a9734cb0e99.png)
[paper notes] a meta reinforcement learning algorithm for causal discovery

How painful is it to write unit tests?

We media people must have four material websites, and don't worry about finding materials anymore

Deep recursion, deep search DFS, backtracking, paper cutting learning.

Design of Butterworth filter and drawing of amplitude frequency characteristic curve

Session and cookie, token and storage

QT Chinese programming encounters c2001 error, prompting "there is a newline character in the constant"
随机推荐
We media people must have four material websites, and don't worry about finding materials anymore
Mysql数据类型
The difference between abstract classes and interface interfaces
为啥谷歌的内部工具不适合你?
QVariant的使用
Tfrecord write and read
Single model common sense reasoning first surpasses human beings! HFL summit openbookqa challenge
Network Security Learning (XIII) data link layer
Kibana~ the process number cannot be found after kibana is started in the background
Opencv compile and call GPU version
Basic knowledge of radar
[MySQL rights] UDF rights (with Malaysia)
Stack simulation queue
[文献阅读] - HRL -[HRL with Universal Policies for Multi-Step Robotic Manipulation]
Can generic types be used in array
[tensorflow] about seed
连续三年成为云AI服务领导者,亚马逊云科技做对了什么?
Learning notes of technical art hundred people plan (2) -- vector
Zcmu--5015: complete the task
[natural language processing] [vector representation] augsbert: improve the data enhancement method of Bi encoders for paired sentence scoring tasks