找回密码
 立即注册
楼主: fjkrl

[脚本] Unity3D炮弹发射与碰撞声音效果脚本

[复制链接]
发表于 2013-3-12 10:41 | 显示全部楼层 |阅读模式
Unity3D炮弹发射与碰撞声音效果脚本
  1. public static bool FileBrowser( ref string location, ref Vector2 directoryScroll, ref Vector2 fileScroll )
  2. {
  3.     bool complete;
  4.     DirectoryInfo directoryInfo;
  5.     DirectoryInfo directorySelection;
  6.     FileInfo fileSelection;
  7.     int contentWidth;
  8.     // Our return state - altered by the "Select" button
  9.     complete = false;
  10.     // Get the directory info of the current location
  11.     fileSelection = new FileInfo( location );
  12.     if( (fileSelection.Attributes & FileAttributes.Directory) == FileAttributes.Directory )
  13.     {
  14.         directoryInfo = new DirectoryInfo( location );
  15.     }
  16.     else
  17.     {
  18.         directoryInfo = fileSelection.Directory;
  19.     }
  20.     if( location != "/" && GUI.Button( new Rect( 10, 20, 410, 20 ), "Up one level" ) )
  21.     {
  22.         directoryInfo = directoryInfo.Parent;
  23.         location = directoryInfo.FullName;
  24.     }
  25.     // Handle the directories list
  26.     GUILayout.BeginArea( new Rect( 10, 40, 200, 300 ) );
  27.         GUILayout.Label( "Directories:" );
  28.         directoryScroll = GUILayout.BeginScrollView( directoryScroll );
  29.             directorySelection = BehaveLibrary.Resources.SelectList( directoryInfo.GetDirectories(), null ) as DirectoryInfo;
  30.         GUILayout.EndScrollView();
  31.     GUILayout.EndArea();
  32.     if( directorySelection != null )
  33.     // If a directory was selected, jump there
  34.     {
  35.         location = directorySelection.FullName;
  36.     }
  37.     // Handle the files list
  38.     GUILayout.BeginArea( new Rect( 220, 40, 200, 300 ) );
  39.         GUILayout.Label( "Files:" );
  40.         fileScroll = GUILayout.BeginScrollView( fileScroll );
  41.             fileSelection = BehaveLibrary.Resources.SelectList( directoryInfo.GetFiles(), null ) as FileInfo;
  42.         GUILayout.EndScrollView();
  43.     GUILayout.EndArea();
  44.     if( fileSelection != null )
  45.     // If a file was selected, update our location to it
  46.     {
  47.         location = fileSelection.FullName;
  48.     }
  49.     // The manual location box and the select button
  50.     GUILayout.BeginArea( new Rect( 10, 350, 410, 20 ) );
  51.     GUILayout.BeginHorizontal();
  52.         location = GUILayout.TextArea( location );
  53.         contentWidth = ( int )GUI.skin.GetStyle( "Button" ).CalcSize( new GUIContent( "Select" ) ).x;
  54.         if( GUILayout.Button( "Select", GUILayout.Width( contentWidth ) ) )
  55.         {
  56.             complete = true;
  57.         }
  58.     GUILayout.EndHorizontal();
  59.     GUILayout.EndArea();
  60.     return complete;
  61. }
  62. 使用
  63.   public void FileBrowserWindow( int idx )
  64.     {
  65.         if( FileBrowser( ref location, ref directoryScroll, ref fileScroll ) )
  66.         {
  67.             fileBrowser = false;
  68.         }
  69.     }
  70.     public void OnGUI()
  71.     {
  72.         if( fileBrowser )
  73.         {
  74.             GUI.Window( 0, new Rect( ( Screen.width - 430 ) / 2, ( Screen.height - 380 ) / 2, 430, 380 ), FileBrowserWindow, "Browse" );
  75.             return;
  76.         }
  77.     }
复制代码
发表于 2013-5-23 12:25 | 显示全部楼层

感谢楼主的无私分享!{:soso__11402694654016840197_7:}
发表于 2017-2-16 19:00 | 显示全部楼层
楼主是超人
发表于 2017-2-16 18:47 | 显示全部楼层
顶顶多好
发表于 2017-2-16 18:52 | 显示全部楼层
真心顶
发表于 2017-2-16 19:00 | 显示全部楼层
难得一见的好帖
发表于 2017-2-16 18:15 | 显示全部楼层
说的非常好
发表于 2017-2-21 07:08 | 显示全部楼层
很不错
发表于 2017-2-21 07:38 | 显示全部楼层
好帖就是要顶
发表于 2017-2-21 07:59 | 显示全部楼层
顶顶多好
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-12-24 02:34 , Processed in 0.092370 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表