zoukankan      html  css  js  c++  java
  • unity判断平台

    using UnityEngine;  
    using System.Collections;  
      
    public class Recompile : MonoBehaviour  
    {  
      
        private string platform = string.Empty;  
        // Use this for initialization  
        void Start()  
        {  
            DebugPlatformMesaage();  
        }  
    void DebugPlatformMesaage()  
    {  
     
    #if UNITY_EDITOR  
            platform = "hi,大家好,我是在unity编辑模式下";  
    #elif UNITY_XBOX360  
           platform="hi,大家好,我在XBOX360平台";  
    #elif UNITY_IPHONE  
           platform="hi,大家好,我是IPHONE平台";  
    #elif UNITY_ANDROID  
           platform="hi,大家好,我是ANDROID平台";  
    #elif UNITY_STANDALONE_OSX  
           platform="hi,大家好,我是OSX平台";  
    #elif UNITY_STANDALONE_WIN  
           platform="hi,大家好,我是Windows平台";  
    #endif  
            Debug.Log("Current Platform:" + platform);  
        }  
    }

     注意一点:如果你写一行代码,想让在Android平台下运行时,如果你如下面这种写法:

    #if UNITY_ANDROID
           // 调用Android的方法
    #endif 

    你会发现在unity运行的时候,会影响socket的访问。

    实际应该这样写:

    #if UNITY_ANDROID && !UNITY_EDITOR
           // 调用Android的方法 
    #endif

    这样就不会出现问题了。

  • 相关阅读:
    ntp时钟同步
    Office2013中文激活版
    Windows2008|2003超出最大连接数
    Vivaldi浏览器媲美Chrome
    Win10激活KMS2.0
    FTP下载工具
    UltraEdit编辑器|UE
    社工-入侵
    实时系统跟分时系统
    ThreadPoolExecutor线程池解析与BlockingQueue的三种实现
  • 原文地址:https://www.cnblogs.com/Colored-Mr/p/5706909.html
Copyright © 2011-2022 走看看