Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
M
MusicBigWatermelon
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
MusicBigWatermelon
Commits
b1a0ee9d
Commit
b1a0ee9d
authored
Aug 03, 2021
by
LiLiuZhou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a8c07a3c
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
300 additions
and
11 deletions
+300
-11
Pause.png
Assets/Artres/PanelPic/MusicPanel/Pause.png
+0
-0
Pause.png.meta
Assets/Artres/PanelPic/MusicPanel/Pause.png.meta
+0
-0
Start.png
Assets/Artres/PanelPic/MusicPanel/Start.png
+0
-0
Start.png.meta
Assets/Artres/PanelPic/MusicPanel/Start.png.meta
+0
-0
MusicMgr.cs
Assets/FunScripts/Core/MusicMgr.cs
+3
-0
MusicPanel.spriteatlas
Assets/Resources/Atlas/MusicPanel.spriteatlas
+44
-0
MusicPanel.spriteatlas.meta
Assets/Resources/Atlas/MusicPanel.spriteatlas.meta
+8
-0
MusicCell.prefab
Assets/Resources/Cells/MusicCell.prefab
+1
-1
MusicPanel.prefab
Assets/Resources/UI/Panel/MusicPanel.prefab
+134
-1
MusicCell.cs
Assets/Scripts/Cell/MusicCell.cs
+71
-5
Fruit.cs
Assets/Scripts/Game/Fruit.cs
+0
-2
MusicPanel.cs
Assets/Scripts/Panel/MusicPanel.cs
+39
-2
No files found.
Assets/Artres/PanelPic/MusicPanel/
暂停@3x
.png
→
Assets/Artres/PanelPic/MusicPanel/
Pause
.png
View file @
b1a0ee9d
File moved
Assets/Artres/PanelPic/MusicPanel/
暂停@3x
.png.meta
→
Assets/Artres/PanelPic/MusicPanel/
Pause
.png.meta
View file @
b1a0ee9d
File moved
Assets/Artres/PanelPic/MusicPanel/
开始@3x
.png
→
Assets/Artres/PanelPic/MusicPanel/
Start
.png
View file @
b1a0ee9d
File moved
Assets/Artres/PanelPic/MusicPanel/
开始@3x
.png.meta
→
Assets/Artres/PanelPic/MusicPanel/
Start
.png.meta
View file @
b1a0ee9d
File moved
Assets/FunScripts/Core/MusicMgr.cs
View file @
b1a0ee9d
using
System.Collections
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine
;
using
UnityEngine.Networking
;
public
class
MusicMgr
:
BaseMgr
<
MusicMgr
>
public
class
MusicMgr
:
BaseMgr
<
MusicMgr
>
{
{
...
@@ -138,4 +139,6 @@ public class MusicMgr : BaseMgr<MusicMgr>
...
@@ -138,4 +139,6 @@ public class MusicMgr : BaseMgr<MusicMgr>
DragingMusic
.
GetComponent
<
AudioSource
>().
Pause
();
DragingMusic
.
GetComponent
<
AudioSource
>().
Pause
();
}
}
}
}
}
}
Assets/Resources/Atlas/MusicPanel.spriteatlas
0 → 100644
View file @
b1a0ee9d
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!687078895
&4343727234628468602
SpriteAtlas
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_Name
:
MusicPanel
m_EditorData
:
serializedVersion
:
2
textureSettings
:
serializedVersion
:
2
anisoLevel
:
1
compressionQuality
:
50
maxTextureSize
:
2048
textureCompression
:
0
filterMode
:
1
generateMipMaps
:
0
readable
:
0
crunchedCompression
:
0
sRGB
:
1
platformSettings
:
[]
packingSettings
:
serializedVersion
:
2
padding
:
4
blockOffset
:
1
allowAlphaSplitting
:
0
enableRotation
:
1
enableTightPacking
:
1
variantMultiplier
:
1
packables
:
-
{
fileID
:
21300000
,
guid
:
de06fc9c6cc871d43a282e9947ad8569
,
type
:
3
}
-
{
fileID
:
21300000
,
guid
:
4ba2a34dd9c70cd4b9d650767139a49f
,
type
:
3
}
bindAsDefault
:
1
m_MasterAtlas
:
{
fileID
:
0
}
m_PackedSprites
:
-
{
fileID
:
21300000
,
guid
:
de06fc9c6cc871d43a282e9947ad8569
,
type
:
3
}
-
{
fileID
:
21300000
,
guid
:
4ba2a34dd9c70cd4b9d650767139a49f
,
type
:
3
}
m_PackedSpriteNamesToIndex
:
-
Start
-
Pause
m_Tag
:
MusicPanel
m_IsVariant
:
0
Assets/Resources/Atlas/MusicPanel.spriteatlas.meta
0 → 100644
View file @
b1a0ee9d
fileFormatVersion: 2
guid: 0cdd583dec719154f9c01d47a867208b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4343727234628468602
userData:
assetBundleName:
assetBundleVariant:
Assets/Resources/Cells/MusicCell.prefab
View file @
b1a0ee9d
...
@@ -424,7 +424,7 @@ MonoBehaviour:
...
@@ -424,7 +424,7 @@ MonoBehaviour:
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
m_Material
:
{
fileID
:
0
}
m_Material
:
{
fileID
:
0
}
m_Color
:
{
r
:
1
,
g
:
0
,
b
:
0
,
a
:
1
}
m_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
m_RaycastTarget
:
1
m_RaycastTarget
:
1
m_Maskable
:
1
m_Maskable
:
1
m_OnCullStateChanged
:
m_OnCullStateChanged
:
...
...
Assets/Resources/UI/Panel/MusicPanel.prefab
View file @
b1a0ee9d
...
@@ -154,6 +154,138 @@ MonoBehaviour:
...
@@ -154,6 +154,138 @@ MonoBehaviour:
m_VerticalOverflow
:
1
m_VerticalOverflow
:
1
m_LineSpacing
:
1
m_LineSpacing
:
1
m_Text
:
"
\u6211\u5408\u6210\u7684\u6B4C\u66F2
"
m_Text
:
"
\u6211\u5408\u6210\u7684\u6B4C\u66F2
"
---
!u!1
&4733793534904436019
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
2931496132081761462
}
-
component
:
{
fileID
:
973893917629565500
}
m_Layer
:
5
m_Name
:
AudioPlayer
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!224
&2931496132081761462
RectTransform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
4733793534904436019
}
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
:
4635386703514042469
}
m_RootOrder
:
2
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
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
100
,
y
:
100
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!82
&973893917629565500
AudioSource
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
4733793534904436019
}
m_Enabled
:
1
serializedVersion
:
4
OutputAudioMixerGroup
:
{
fileID
:
0
}
m_audioClip
:
{
fileID
:
0
}
m_PlayOnAwake
:
1
m_Volume
:
1
m_Pitch
:
1
Loop
:
0
Mute
:
0
Spatialize
:
0
SpatializePostEffects
:
0
Priority
:
128
DopplerLevel
:
1
MinDistance
:
1
MaxDistance
:
500
Pan2D
:
0
rolloffMode
:
0
BypassEffects
:
0
BypassListenerEffects
:
0
BypassReverbZones
:
0
rolloffCustomCurve
:
serializedVersion
:
2
m_Curve
:
-
serializedVersion
:
3
time
:
0
value
:
1
inSlope
:
0
outSlope
:
0
tangentMode
:
0
weightedMode
:
0
inWeight
:
0.33333334
outWeight
:
0.33333334
-
serializedVersion
:
3
time
:
1
value
:
0
inSlope
:
0
outSlope
:
0
tangentMode
:
0
weightedMode
:
0
inWeight
:
0.33333334
outWeight
:
0.33333334
m_PreInfinity
:
2
m_PostInfinity
:
2
m_RotationOrder
:
4
panLevelCustomCurve
:
serializedVersion
:
2
m_Curve
:
-
serializedVersion
:
3
time
:
0
value
:
0
inSlope
:
0
outSlope
:
0
tangentMode
:
0
weightedMode
:
0
inWeight
:
0.33333334
outWeight
:
0.33333334
m_PreInfinity
:
2
m_PostInfinity
:
2
m_RotationOrder
:
4
spreadCustomCurve
:
serializedVersion
:
2
m_Curve
:
-
serializedVersion
:
3
time
:
0
value
:
0
inSlope
:
0
outSlope
:
0
tangentMode
:
0
weightedMode
:
0
inWeight
:
0.33333334
outWeight
:
0.33333334
m_PreInfinity
:
2
m_PostInfinity
:
2
m_RotationOrder
:
4
reverbZoneMixCustomCurve
:
serializedVersion
:
2
m_Curve
:
-
serializedVersion
:
3
time
:
0
value
:
1
inSlope
:
0
outSlope
:
0
tangentMode
:
0
weightedMode
:
0
inWeight
:
0.33333334
outWeight
:
0.33333334
m_PreInfinity
:
2
m_PostInfinity
:
2
m_RotationOrder
:
4
---
!u!1
&6443396136560327243
---
!u!1
&6443396136560327243
GameObject
:
GameObject
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
@@ -407,7 +539,7 @@ MonoBehaviour:
...
@@ -407,7 +539,7 @@ MonoBehaviour:
m_StartCorner
:
0
m_StartCorner
:
0
m_StartAxis
:
0
m_StartAxis
:
0
m_CellSize
:
{
x
:
750
,
y
:
120
}
m_CellSize
:
{
x
:
750
,
y
:
120
}
m_Spacing
:
{
x
:
0
,
y
:
3.06
}
m_Spacing
:
{
x
:
0
,
y
:
-5
}
m_Constraint
:
1
m_Constraint
:
1
m_ConstraintCount
:
1
m_ConstraintCount
:
1
---
!u!114
&2864378883970242340
---
!u!114
&2864378883970242340
...
@@ -528,6 +660,7 @@ RectTransform:
...
@@ -528,6 +660,7 @@ RectTransform:
m_Children
:
m_Children
:
-
{
fileID
:
3609245793505339117
}
-
{
fileID
:
3609245793505339117
}
-
{
fileID
:
1269257140283984089
}
-
{
fileID
:
1269257140283984089
}
-
{
fileID
:
2931496132081761462
}
m_Father
:
{
fileID
:
0
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
...
...
Assets/Scripts/Cell/MusicCell.cs
View file @
b1a0ee9d
using
System.Collections
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine
;
using
UnityEngine.Events
;
using
UnityEngine.Networking
;
using
UnityEngine.U2D
;
using
UnityEngine.UI
;
using
UnityEngine.UI
;
public
class
MusicCell
:
BasePanel
public
class
MusicCell
:
BasePanel
{
{
public
SongItemBean
bean
;
public
SongItemBean
bean
;
public
bool
IsPlaying
=
false
;
public
override
void
OnHide
(
object
data
=
null
)
public
override
void
OnHide
(
object
data
=
null
)
{
{
...
@@ -26,6 +32,8 @@ public class MusicCell : BasePanel
...
@@ -26,6 +32,8 @@ public class MusicCell : BasePanel
GetControl
<
Text
>(
"txtNum"
).
color
=
bean
.
song_id
<=
3
?
Color
.
red
:
Color
.
black
;
GetControl
<
Text
>(
"txtNum"
).
color
=
bean
.
song_id
<=
3
?
Color
.
red
:
Color
.
black
;
GetControl
<
Text
>(
"txtMusicName"
).
text
=
bean
.
song_name
;
GetControl
<
Text
>(
"txtMusicName"
).
text
=
bean
.
song_name
;
MonoMgr
.
Getinstance
().
StartCoroutine
(
GetTexture
(
bean
.
song_cover
,
GetControl
<
Image
>(
"imgMusicPic"
)));
}
}
public
override
void
OnRefresh
(
object
data
=
null
)
public
override
void
OnRefresh
(
object
data
=
null
)
...
@@ -35,17 +43,75 @@ public class MusicCell : BasePanel
...
@@ -35,17 +43,75 @@ public class MusicCell : BasePanel
public
void
OnStartMusic
()
public
void
OnStartMusic
()
{
{
if
(
bean
==
null
)
GetControl
<
Image
>(
"btnPlayMusic"
).
sprite
=
Resources
.
Load
<
SpriteAtlas
>(
"Atlas/MusicPanel"
).
GetSprite
(
"Start"
);
//开始获取音频
MonoMgr
.
Getinstance
().
StartCoroutine
(
GetAudioClip
(
bean
.
song_play
,
clip
=>
{
{
throw
new
System
.
Exception
(
"cell数据为空"
);
MusicPanel
panel
=
UIMgr
.
Getinstance
().
GetPanel
<
MusicPanel
>();
}
if
(
panel
==
null
)
return
;
//如果当前面板播放的音乐不是自己
if
(
panel
.
PlayingCell
!=
this
)
return
;
//如果当前正在播放
if
(
panel
.
IsPlayingMusic
())
return
;
panel
.
PlayMusic
(
clip
);
}));
}
}
public
void
OnStopMusic
()
public
void
OnStopMusic
()
{
{
if
(
bean
==
null
)
GetControl
<
Image
>(
"btnPlayMusic"
).
sprite
=
Resources
.
Load
<
SpriteAtlas
>(
"Atlas/MusicPanel"
).
GetSprite
(
"Pause"
);
MusicPanel
panel
=
UIMgr
.
Getinstance
().
GetPanel
<
MusicPanel
>();
panel
.
StopMusic
();
}
//设置图片的方法
IEnumerator
GetTexture
(
string
URL
,
Image
img
)
{
using
(
UnityWebRequest
uwr
=
UnityWebRequestTexture
.
GetTexture
(
URL
))
{
{
throw
new
System
.
Exception
(
"cell数据为空"
);
yield
return
uwr
.
SendWebRequest
();
if
(
uwr
.
isNetworkError
||
uwr
.
isHttpError
)
{
Debug
.
Log
(
uwr
.
error
);
}
else
{
// Get downloaded asset bundle
Texture2D
texture
=
DownloadHandlerTexture
.
GetContent
(
uwr
);
Sprite
sp
=
Sprite
.
Create
(
texture
,
new
Rect
(
0
,
0
,
texture
.
width
,
texture
.
height
),
Vector2
.
zero
);
img
.
sprite
=
sp
;
}
}
}
}
}
//设置音频的方法
IEnumerator
GetAudioClip
(
string
URL
,
UnityAction
<
AudioClip
>
callback
)
{
using
(
UnityWebRequest
www
=
UnityWebRequestMultimedia
.
GetAudioClip
(
URL
,
AudioType
.
WAV
))
{
yield
return
www
.
SendWebRequest
();
if
(
www
.
isNetworkError
)
{
Debug
.
Log
(
www
.
error
);
}
else
{
callback
.
Invoke
(
DownloadHandlerAudioClip
.
GetContent
(
www
));
}
}
}
}
}
Assets/Scripts/Game/Fruit.cs
View file @
b1a0ee9d
...
@@ -48,8 +48,6 @@ public class Fruit : MonoBehaviour
...
@@ -48,8 +48,6 @@ public class Fruit : MonoBehaviour
int
fruitNum
=
int
.
Parse
(
gameObject
.
name
)
+
1
;
int
fruitNum
=
int
.
Parse
(
gameObject
.
name
)
+
1
;
string
NewObjName
=
fruitNum
.
ToString
();
string
NewObjName
=
fruitNum
.
ToString
();
GameObject
Obj
=
Instantiate
(
Resources
.
Load
<
GameObject
>(
"Fruits/"
+
NewObjName
),
MidPos
,
Quaternion
.
identity
);
GameObject
Obj
=
Instantiate
(
Resources
.
Load
<
GameObject
>(
"Fruits/"
+
NewObjName
),
MidPos
,
Quaternion
.
identity
);
Obj
.
transform
.
localScale
=
new
Vector3
(
0.3f
,
0.3f
,
1
);
Obj
.
transform
.
localScale
=
new
Vector3
(
0.3f
,
0.3f
,
1
);
Obj
.
name
=
NewObjName
;
Obj
.
name
=
NewObjName
;
...
...
Assets/Scripts/Panel/MusicPanel.cs
View file @
b1a0ee9d
...
@@ -8,6 +8,8 @@ public class MusicPanel : BasePanel
...
@@ -8,6 +8,8 @@ public class MusicPanel : BasePanel
{
{
//当前正在播放的格子
//当前正在播放的格子
public
MusicCell
PlayingCell
;
public
MusicCell
PlayingCell
;
public
AudioSource
AS
;
public
override
void
OnHide
(
object
data
=
null
)
public
override
void
OnHide
(
object
data
=
null
)
{
{
...
@@ -16,6 +18,8 @@ public class MusicPanel : BasePanel
...
@@ -16,6 +18,8 @@ public class MusicPanel : BasePanel
public
override
void
OnInit
(
object
data
=
null
)
public
override
void
OnInit
(
object
data
=
null
)
{
{
GetControl
<
Button
>(
"btnBack"
).
onClick
.
AddListener
(()
=>{
UIMgr
.
Getinstance
().
HidePanel
<
MusicPanel
>();
});
GetControl
<
Button
>(
"btnBack"
).
onClick
.
AddListener
(()
=>{
UIMgr
.
Getinstance
().
HidePanel
<
MusicPanel
>();
});
AS
=
GetComponentInChildren
<
AudioSource
>();
#
region
通过数据初始化面板
#
region
通过数据初始化面板
...
@@ -46,7 +50,40 @@ public class MusicPanel : BasePanel
...
@@ -46,7 +50,40 @@ public class MusicPanel : BasePanel
public
void
ChangeMusic
(
MusicCell
cell
)
public
void
ChangeMusic
(
MusicCell
cell
)
{
{
//如果正在播放的和点击的歌曲相同 表示 用户正在关闭当前播放的音乐
if
(
PlayingCell
==
cell
)
{
cell
.
OnStopMusic
();
PlayingCell
=
null
;
return
;
}
PlayingCell
?.
OnStopMusic
();
PlayingCell
=
cell
;
cell
.
OnStartMusic
();
}
public
bool
IsPlayingMusic
()
{
if
(
AS
.
clip
==
null
)
return
false
;
return
AS
.
isPlaying
;
}
public
void
PlayMusic
(
AudioClip
clip
)
{
AS
.
clip
=
clip
;
AS
.
loop
=
true
;
AS
.
Play
();
}
}
public
void
StopMusic
()
{
AS
.
Stop
();
AS
.
clip
=
null
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment