Skip to content

Commit

Permalink
android platform transplant?
Browse files Browse the repository at this point in the history
file read failling
  • Loading branch information
StellEdge committed Mar 18, 2021
1 parent f7f4685 commit 1597c08
Show file tree
Hide file tree
Showing 10 changed files with 418 additions and 24 deletions.
11 changes: 3 additions & 8 deletions Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_2019_4_20;UNITY_2019_4;UNITY_2019;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_3_OR_NEWER;UNITY_2018_4_OR_NEWER;UNITY_2019_1_OR_NEWER;UNITY_2019_2_OR_NEWER;UNITY_2019_3_OR_NEWER;UNITY_2019_4_OR_NEWER;PLATFORM_ARCH_64;UNITY_64;UNITY_INCLUDE_TESTS;ENABLE_AR;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_EVENT_QUEUE;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_TEXTURE_STREAMING;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_UNITYWEBREQUEST;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_AUDIO_JOBS;INCLUDE_DYNAMIC_GI;ENABLE_MONO_BDWGC;ENABLE_SCRIPTING_GC_WBARRIERS;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_VIDEO;PLATFORM_STANDALONE;PLATFORM_STANDALONE_WIN;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_OUT_OF_PROCESS_CRASH_HANDLER;ENABLE_CLUSTER_SYNC;ENABLE_CLUSTERINPUT;GFXDEVICE_WAITFOREVENT_MESSAGEPUMP;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;NET_STANDARD_2_0;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE;ENABLE_VSTU;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_LOCALIZATION;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_LEGACY_INPUT_MANAGER;CSHARP_7_OR_LATER;CSHARP_7_3_OR_NEWER</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_2019_4_20;UNITY_2019_4;UNITY_2019;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_3_OR_NEWER;UNITY_2018_4_OR_NEWER;UNITY_2019_1_OR_NEWER;UNITY_2019_2_OR_NEWER;UNITY_2019_3_OR_NEWER;UNITY_2019_4_OR_NEWER;UNITY_INCLUDE_TESTS;ENABLE_AR;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_EVENT_QUEUE;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_TEXTURE_STREAMING;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_UNITYWEBREQUEST;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_NATIVE_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_AUDIO_JOBS;ENABLE_RUNTIME_PERMISSIONS;ENABLE_ENGINE_CODE_STRIPPING;ENABLE_ONSCREEN_KEYBOARD;INCLUDE_DYNAMIC_GI;ENABLE_MONO_BDWGC;ENABLE_SCRIPTING_GC_WBARRIERS;PLATFORM_SUPPORTS_MONO;ENABLE_VIDEO;PLATFORM_ANDROID;UNITY_ANDROID;UNITY_ANDROID_API;ENABLE_EGL;ENABLE_NETWORK;ENABLE_RUNTIME_GI;ENABLE_CRUNCH_TEXTURE_COMPRESSION;PLATFORM_SUPPORTS_ADS_ID;UNITY_CAN_SHOW_SPLASH_SCREEN;UNITY_HAS_GOOGLEVR;UNITY_HAS_TANGO;ENABLE_SPATIALTRACKING;UNITY_ASTC_ONLY_DECOMPRESS;ENABLE_UNITYADS_RUNTIME;UNITY_UNITYADS_API;ENABLE_MONO;NET_STANDARD_2_0;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE;ENABLE_VSTU;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_LOCALIZATION;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_LEGACY_INPUT_MANAGER;CSHARP_7_OR_LATER;CSHARP_7_3_OR_NEWER</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
Expand All @@ -49,7 +49,7 @@
<UnityProjectGenerator>Unity/VSTU</UnityProjectGenerator>
<UnityProjectGeneratorVersion>4.9.1.0</UnityProjectGeneratorVersion>
<UnityProjectType>Game:1</UnityProjectType>
<UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
<UnityBuildTarget>Android:13</UnityBuildTarget>
<UnityVersion>2019.4.20f1c1</UnityVersion>
</PropertyGroup>
<ItemGroup>
Expand Down Expand Up @@ -84,6 +84,7 @@
<Compile Include="Assets\scripts\Spectrum.cs" />
<Compile Include="Assets\scripts\WheelItemButton.cs" />
<Compile Include="Assets\scripts\csvLoader.cs" />
<Compile Include="Assets\scripts\debugtext.cs" />
<Reference Include="UnityEngine">
<HintPath>C:/Program Files/Unity/Hub/Editor/2019.4.20f1c1/Editor/Data/Managed/UnityEngine/UnityEngine.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -111,12 +112,6 @@
<Reference Include="UnityEngine.ClothModule">
<HintPath>C:/Program Files/Unity/Hub/Editor/2019.4.20f1c1/Editor/Data/Managed/UnityEngine/UnityEngine.ClothModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ClusterInputModule">
<HintPath>C:/Program Files/Unity/Hub/Editor/2019.4.20f1c1/Editor/Data/Managed/UnityEngine/UnityEngine.ClusterInputModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.ClusterRendererModule">
<HintPath>C:/Program Files/Unity/Hub/Editor/2019.4.20f1c1/Editor/Data/Managed/UnityEngine/UnityEngine.ClusterRendererModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>C:/Program Files/Unity/Hub/Editor/2019.4.20f1c1/Editor/Data/Managed/UnityEngine/UnityEngine.CoreModule.dll</HintPath>
</Reference>
Expand Down
18 changes: 18 additions & 0 deletions Assets/Plugins/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unity3d.player"
xmlns:tools="http://schemas.android.com/tools">
<application>
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:theme="@style/UnityThemeSelector">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
</application>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE " />
</manifest>
167 changes: 167 additions & 0 deletions Assets/Scenes/gameplay.unity
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ RectTransform:
- {fileID: 85128991}
- {fileID: 676209737}
- {fileID: 775839459}
- {fileID: 2000048559}
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -3989,6 +3990,172 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1919517976}
m_CullTransparentMesh: 0
--- !u!1 &2000048558
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2000048559}
- component: {fileID: 2000048562}
- component: {fileID: 2000048561}
- component: {fileID: 2000048560}
m_Layer: 5
m_Name: DebugText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2000048559
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2000048558}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 195393353}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -305.5, y: -259.2}
m_SizeDelta: {x: 397.09326, y: 37.579346}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2000048560
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2000048558}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c867419884d8c8942a0824a97f7c012a, type: 3}
m_Name:
m_EditorClassIdentifier:
style:
m_Name:
m_Normal:
m_Background: {fileID: 0}
m_ScaledBackgrounds: []
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_Hover:
m_Background: {fileID: 0}
m_ScaledBackgrounds: []
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_Active:
m_Background: {fileID: 0}
m_ScaledBackgrounds: []
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_Focused:
m_Background: {fileID: 0}
m_ScaledBackgrounds: []
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_OnNormal:
m_Background: {fileID: 0}
m_ScaledBackgrounds: []
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_OnHover:
m_Background: {fileID: 0}
m_ScaledBackgrounds: []
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_OnActive:
m_Background: {fileID: 0}
m_ScaledBackgrounds: []
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_OnFocused:
m_Background: {fileID: 0}
m_ScaledBackgrounds: []
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_Border:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Margin:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Overflow:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Font: {fileID: 0}
m_FontSize: 0
m_FontStyle: 0
m_Alignment: 0
m_WordWrap: 0
m_RichText: 1
m_TextClipping: 0
m_ImagePosition: 0
m_ContentOffset: {x: 0, y: 0}
m_FixedWidth: 0
m_FixedHeight: 0
m_StretchWidth: 1
m_StretchHeight: 0
rect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
IntervalSize: 16
ClearTime: 1
--- !u!114 &2000048561
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2000048558}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!222 &2000048562
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2000048558}
m_CullTransparentMesh: 0
--- !u!1 &2115507993
GameObject:
m_ObjectHideFlags: 0
Expand Down
13 changes: 12 additions & 1 deletion Assets/scripts/MusicData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static int GetWheelItemCount()
public class MusicDataPath
{
public static string MUSICPATH_DEBUG = "D:/Unitykit/MusicData/";

public static string MUSICPATH_ANDROID = Application.persistentDataPath+ "/MusicData/";
public static string MUSICPATH = System.Environment.CurrentDirectory+"/MusicData/";
//result: X:\xxx\xxx(.exe文件所在的目录)
}
Expand Down Expand Up @@ -83,3 +83,14 @@ public MusicFolder(){
musicdata = new List<MusicData>();
}
}

public static class FileManager
{
public static byte[] ReadBytes(string path)
{
byte[] bytes = new byte[0];
//在这里做文件读取

return bytes;
}
}
13 changes: 9 additions & 4 deletions Assets/scripts/MusicLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ public static void InitMusicLoader()
{
MUSICPATH = MusicDataPath.MUSICPATH_DEBUG;
}

if (!Directory.Exists(MUSICPATH))
{
MUSICPATH = MusicDataPath.MUSICPATH_ANDROID;
}
//MUSICPATH = MusicDataPath.MUSICPATH_ANDROID;
debugtext.Add("MyDebug", "MUSICPATH " + MUSICPATH);
Debug.Log("MUSICPATH " + MUSICPATH);
musicfolders = new List<MusicFolder>();
MusicFolder temp_musicfolder;
MusicData temp_music = new MusicData();
Expand All @@ -50,8 +56,8 @@ public static void InitMusicLoader()
temp_musicfolder.musicdata.Clear();
foreach(string[] info in musiclist){
//temp_music.SetMusicData(info);
info[6] = MUSICPATH + musicsets[i].Name + '/' + info[6];
info[7] = MUSICPATH + musicsets[i].Name + '/' + info[7];
info[6] = MUSICPATH + musicsets[i].Name + "//" + info[6];
info[7] = MUSICPATH + musicsets[i].Name + "//" + info[7];
temp_musicfolder.musicdata.Add(new MusicData(info));
}
Debug.Log( "Loaded pack csv:" + musicsets[i].Name );
Expand Down Expand Up @@ -112,7 +118,6 @@ private static void ReadAndLoadMusicFolderAsync(object obj)
{
MusicFolder mf = obj as MusicFolder;
Debug.Log("Start loading " + mf.Name);
AudioClip clip;
foreach (MusicData md in mf.musicdata)
{
//string musicfilepath = cLocalPath + md.music;
Expand Down
13 changes: 12 additions & 1 deletion Assets/scripts/MusicPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ public static void LoadAudio(string audioName, string path)
{
return;
}
if (!File.Exists(path))
{
Debug.Log("No such file:" + path);
debugtext.Add("MyDebug", "No such file: " + path);
}

AudioClip clip;
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
debugtext.Add("Music Loading",path);
fileStream.Seek(0, SeekOrigin.Begin);
//创建文件长度缓冲区
byte[] bytes = new byte[fileStream.Length];
Expand All @@ -87,15 +94,19 @@ public static void LoadAudio(string audioName, string path)
fileStream.Close();
fileStream.Dispose();
fileStream = null;
/*
if (bytes.Length != 0)
{
//WWW www = new WWW(musicfilepath);
clip = NAudioPlayer.FromMp3Data(bytes);
}
else
{
clip = null;
}
debugtext.Add("MyDebug", "Load " + audioName + "failed");
}*/
clip = NAudioPlayer.FromMp3Data(bytes);
audioDic.Add(audioName, clip);
Debug.Log("Load " + audioName);
}
Expand Down
1 change: 0 additions & 1 deletion Assets/scripts/MusicWheelItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public void ButtonClicked()
fileStream.Close();
fileStream.Dispose();
fileStream = null;

//创建Texture
//int width = 570;
//int height = 880;
Expand Down
Loading

0 comments on commit 1597c08

Please sign in to comment.