大将军 发表于 2012-12-6 13:27

Unity IOS常用代码控制源码 带测试场景

using UnityEngine;
using System.Collections.Generic;


public class MobclixGUIManager : MonoBehaviour
{
    void OnStart()
    {
      Screen.orientation = ScreenOrientation.LandscapeLeft;
    }
   
   
    void OnGUI()
    {
      float yPos = 5.0f;
      float xPos = 20.0f;
      float width = 210.0f;
      float height = 40.0f;
      float heightPlus = 45.0f;
      
      
      if( GUI.Button( new Rect( xPos, yPos, width, height ), "Initialize Mobclix" ) )
      {
            MobclixBinding.start();
      }
      
      
      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Show Banner" ) )
      {
            MobclixBinding.showBanner();
      }
      
      
      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Hide Banner" ) )
      {
            MobclixBinding.hideBanner( true );
      }
      
      
      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Request Full Screen Ad" ) )
      {
            MobclixBinding.requestFullScreenAd();
      }
      
      
      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Is Full Screen Ad Loaded?" ) )
      {
            Debug.Log( "is full screen ad ready? " + MobclixBinding.isFullScreenAdReady() );
      }
      
      
      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Display Full Screen Ad" ) )
      {
            MobclixBinding.displayFullScreenAd();
      }


      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Request and Display Full Screen" ) )
      {
            MobclixBinding.requestAndDisplayFullScreenAd();
      }
      
      
      xPos = Screen.width - width - 20.0f;
      yPos = 5.0f;
      
      if( iPhoneSettings.generation != iPhoneGeneration.iPad1Gen )
      {
            if( GUI.Button( new Rect( xPos, yPos, width, height ), "320x50 Banner" ) )
            {
                MobclixBinding.createBanner( MobclixBannerType.iPhone_320x50, ( Screen.width - 320 ) / 2, 0 );
            }
      
            if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "320x250 Banner" ) )
            {
                MobclixBinding.createBanner( MobclixBannerType.iPhone_300x250, ( Screen.width - 300 ) / 2, 0 );
            }
      }
      else
      {
            if( GUI.Button( new Rect( xPos, yPos, width, height ), "120x600 Banner" ) )
            {
                MobclixBinding.createBanner( MobclixBannerType.iPad_120x600, ( Screen.width - 120 ) / 2, 0 );
            }
            
            
            if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "468x60 Banner" ) )
            {
                MobclixBinding.createBanner( MobclixBannerType.iPad_468x60, 0, 0 );
            }
            
            
            if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "728x90 Banner" ) )
            {
                MobclixBinding.createBanner( MobclixBannerType.iPad_728x90, ( Screen.width - 728 ) / 2, 0 );
            }
            
            
            if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "300x250 Banner" ) )
            {
                MobclixBinding.createBanner( MobclixBannerType.iPad_300x250, ( Screen.width - 300 ) / 2, 0 );
            }
      }
      
      
      
      
      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Force Portrait Banner" ) )
      {
            MobclixBinding.rotateToOrientation( DeviceOrientation.Portrait );
      }
      
      
      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Force LandcapeLeft Banner" ) )
      {
            MobclixBinding.rotateToOrientation( DeviceOrientation.LandscapeLeft );
      }
      
      
      if( GUI.Button( new Rect( xPos, yPos += heightPlus, width, height ), "Force LandcapeRight Banner" ) )
      {
            MobclixBinding.rotateToOrientation( DeviceOrientation.LandscapeRight );
      }
    }


}

animan 发表于 2013-3-5 12:54

{:5_424:}{:5_424:}{:5_424:}

张某 发表于 2013-3-20 12:13


膜拜中。。。。{:soso__7524161091986203637_5:}

张某 发表于 2013-3-20 12:13


也不能一竿子打死呀!{:soso__11174995096617402082_3:}

张某 发表于 2013-3-20 12:14


膜拜中。。。。{:soso__7524161091986203637_5:}

张某 发表于 2013-3-20 12:15


不错 不错 不错{:soso__3922851084632044791_6:}

张某 发表于 2013-3-20 19:24


也不能一竿子打死呀!{:soso__11174995096617402082_3:}

疯子大狗 发表于 2013-4-4 23:50


感谢楼主的无私分享!{:soso__11402694654016840197_7:}

haorenye 发表于 2013-5-10 16:29

学习了,谢谢分享

wangjiaoren 发表于 2013-6-5 13:44

看看怎么实现的
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: Unity IOS常用代码控制源码 带测试场景