fixed layering

This commit is contained in:
Rapandrasmus 2023-08-07 23:20:50 +02:00
parent 3b1a480f3a
commit a05047e08b
3 changed files with 16 additions and 20 deletions

View file

@ -179,6 +179,7 @@ GameObject:
- component: {fileID: 7591110402097765485}
- component: {fileID: 7211266264008123551}
- component: {fileID: -9193613041847046406}
- component: {fileID: -7082706312707440325}
m_Layer: 0
m_Name: YellowMonkey
m_TagString: Untagged
@ -244,6 +245,18 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
isPink: 0
monkeyBeat: 0
--- !u!210 &-7082706312707440325
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3151069026564347634}
m_Enabled: 1
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 50
--- !u!1 &4343136497418508153
GameObject:
m_ObjectHideFlags: 0

View file

@ -178,7 +178,6 @@ GameObject:
m_Component:
- component: {fileID: 2594505700513810575}
- component: {fileID: 4157700164771259173}
- component: {fileID: 6295735035881919980}
m_Layer: 0
m_Name: watchHole
m_TagString: Untagged
@ -224,14 +223,3 @@ Animator:
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!210 &6295735035881919980
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8325540476350084961}
m_Enabled: 1
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0

View file

@ -25,17 +25,9 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
private void Awake()
{
game = MonkeyWatch.instance;
int sortIndex = 0;
bool goDown = false;
for (int i = 0; i < 60; i++)
{
watchHoles.Add(transform.GetChild(i));
watchHoles[i].GetComponent<SortingGroup>().sortingOrder = sortIndex;
sortIndex += goDown ? -1 : 1;
if (sortIndex >= 30)
{
goDown = true;
}
}
}
@ -63,6 +55,9 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch
WatchMonkey spawnedMonkey = Instantiate(isPink ? pinkMonkeyRef : yellowMonkeyRef, hole);
spawnedMonkey.Appear(beat, instant, hole.GetComponent<Animator>(), GetMonkeyAngle(index));
spawnedMonkey.transform.eulerAngles = Vector3.zero;
var sortingGroup = spawnedMonkey.GetComponent<SortingGroup>();
if (index <= 30) sortingGroup.sortingOrder = 50 + watchHoleIndex;
else sortingGroup.sortingOrder = 50 + watchHoleIndex - (watchHoleIndex - 29);
currentMonkeys.Add(spawnedMonkey);
if (currentMonkeys.Count > maxMonkeys)
{