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

    这样就不会出现问题了。

  • 相关阅读:
    Add two numbers
    House Robber && House Robber II
    Clone Graph
    224. Basic Calculator
    29. Divide Two Integers
    365. Water and Jug Problem
    435. Non-overlapping Intervals
    452. Minimum Number of Arrows to Burst Balloons
    138. Copy List with Random Pointer
    43. Multiply Strings
  • 原文地址:https://www.cnblogs.com/Colored-Mr/p/5706909.html
Copyright © 2011-2022 走看看