Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6aa6855
remove gem icon
alyhung Apr 24, 2024
192492b
create new mainmenu by coppying 2-Scene and deleting unnecessary items
alyhung Apr 24, 2024
296cdf3
add three buttons to direct scenes
alyhung Apr 26, 2024
59daf1d
change ConfigurationManager to non-static & non-singleton to resuse o…
alyhung May 3, 2024
dd20624
active Canvas-PauseGame to avoid touch control issue
alyhung May 3, 2024
93428fa
set flag CUTOUT_MODE_ALWAYS for the activity
alyhung May 6, 2024
d503b7c
add rotatable buttons & introes to mainmenu
alyhung May 6, 2024
2febc14
enable display cutout always
alyhung May 6, 2024
f568f00
add close button to child scenes
hungaly May 7, 2024
b9685fe
add mainmenu scene's layout for butotns on tabletop mode
hungaly May 7, 2024
2327c1f
add hinge text & control for mainmenu scene
alyhung May 7, 2024
ee65190
add delay to Anchoring scene to avoid bad ratio control
alyhung May 7, 2024
3b20e1b
remove unused object
alyhung May 7, 2024
128a740
reset time scale to avoid controlling issue
alyhung May 7, 2024
ddb679d
delay one frame when deal with onConfigurationChange in Anchoring scene
alyhung May 9, 2024
28e4c85
fix back buttons
alyhung May 13, 2024
763cb9c
fix gradient background on wide devices
alyhung May 13, 2024
65f11b4
adjust main camera for wide devies
alyhung May 13, 2024
d0e48f5
adjust background objects for wide devices
alyhung May 13, 2024
c11c011
fix issue at game start where mainmenu scene detects wrong orientation
alyhung May 13, 2024
6424db6
adjust mainmenu UI in tabletop mode
alyhung May 13, 2024
5d0ccdd
update java code to follow Andoid guidance on detecting fold events
alyhung May 13, 2024
db023ac
add fake cam to anchoring scene to avoid cache frame. Pause game for …
alyhung May 13, 2024
7645c53
move the Window info listener to activity create
alyhung May 15, 2024
a63916d
add pause scene into fold change to postpone the camera manipulating …
alyhung May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Assets/Gameplay/Close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions Assets/Gameplay/Close.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 56 additions & 25 deletions Assets/Plugins/Android/LargeScreenPlayableActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Bundle;
import android.os.Build;
import android.view.WindowManager;
import android.util.Log;
import android.view.Display;
import android.util.DisplayMetrics;
Expand All @@ -31,6 +33,9 @@
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;



import static androidx.core.content.ContextCompat.getSystemService;


Expand All @@ -42,22 +47,31 @@ public class LargeScreenPlayableActivity extends UnityPlayerActivity {
private float lastValue = -1.0f;

static Context mContext;
WindowLayoutInfo lastLayoutInfo = null;
FoldingFeature lastFoldingFeature = null;
WindowInfoTrackerCallbackAdapter wit;
private final LayoutStateChangeCallback layoutStateChangeCallback =
new LayoutStateChangeCallback();


@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
mContext = this;
wit = new WindowInfoTrackerCallbackAdapter(WindowInfoTracker.Companion.getOrCreate(this));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
}

wit = new WindowInfoTrackerCallbackAdapter(WindowInfoTracker.getOrCreate(this));
wit.addWindowLayoutInfoListener(
this, Runnable::run, layoutStateChangeCallback);
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.d(TAG, newConfig.toString());

Log.d(TAG, "on Configuration changed: " + newConfig.toString());

// winConfig={ mBounds=Rect(0, 0 - 1080, 2092) mAppBounds=Rect(0, 0 - 1080, 1896) mMaxBounds=Rect(0, 0 - 1080, 2092) mDisplayRotation=ROTATION_180 mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_180}}
try {
Expand All @@ -78,9 +92,7 @@ else if (rotation == Surface.ROTATION_270)
json.put("orientation", "ORIENTATION_PORTRAIT");
else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
json.put("orientation", "ORIENTATION_LANDSCAPE");
// else if (newConfig.orientation == Configuration.ORIENTATION_SQUARE) <-- deprecated in API level 16
// json.put("orientation", "ORIENTATION_SQUARE");
else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
else
json.put("orientation", "ORIENTATION_UNDEFINED");

DisplayMetrics screenMetrics = new DisplayMetrics();
Expand All @@ -101,7 +113,7 @@ else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
}
}

protected void HandleFoldingFeatures(FoldingFeature foldingFeature) {
protected void HandleFoldingFeatures(FoldingFeature foldingFeature) {
try {
JSONObject json = new JSONObject();
if (foldingFeature != null) {
Expand All @@ -126,34 +138,43 @@ protected void HandleFoldingFeatures(FoldingFeature foldingFeature) {
} else {
json.put("state", "CLOSED");
}

Log.d(TAG, "HandleFoldingFeatures: " + json.toString());
mUnityPlayer.UnitySendMessage("ConfigurationManager", "onFoldChanged", json.toString());
} catch (JSONException e) {
Log.d(TAG, "Exception json");
throw new RuntimeException(e);
}
}

@Override
protected void onStart() {
super.onStart();
wit.addWindowLayoutInfoListener(this, runOnUiThreadExecutor(), (newLayoutInfo -> {
lastLayoutInfo = newLayoutInfo;
}

lastFoldingFeature = null;
if (newLayoutInfo.getDisplayFeatures().size() > 0) {
newLayoutInfo.getDisplayFeatures().forEach(displayFeature -> {
@Override
protected void onStop() {
super.onStop();
}

protected void onLayoutStateChange(WindowLayoutInfo newLayoutInfo){
Log.d(TAG, "onLayoutStateChange: " + newLayoutInfo.toString());

lastFoldingFeature = null;
if (newLayoutInfo.getDisplayFeatures().size() > 0) {
newLayoutInfo.getDisplayFeatures().forEach(displayFeature -> {
if(displayFeature instanceof FoldingFeature)
{
// only set if it's a fold, not other feature type. only works for single-fold devices.
FoldingFeature foldingFeature = (FoldingFeature)displayFeature;
if (foldingFeature != null)
{ // only set if it's a fold, not other feature type. only works for single-fold devices.
lastFoldingFeature = foldingFeature;
HandleFoldingFeatures(foldingFeature);
Log.d(TAG, "Fold changed: " + foldingFeature.toString());

} else {
Log.d(TAG, "Fold changed: [Closed]");
}
});
}
}));
lastFoldingFeature = foldingFeature;
HandleFoldingFeatures(foldingFeature);
Log.d(TAG, "Fold changed: " + foldingFeature.toString());

} else {
Log.d(TAG, "Fold changed: [Closed]");
}
});
}
}

Executor runOnUiThreadExecutor()
Expand All @@ -174,4 +195,14 @@ public FoldingFeature getFoldingFeature()
{
return lastFoldingFeature;
}

class LayoutStateChangeCallback implements Consumer<WindowLayoutInfo> {
@Override
public void accept(WindowLayoutInfo newLayoutInfo) {
// Use newLayoutInfo to update the Layout
LargeScreenPlayableActivity.this.runOnUiThread( () -> {
LargeScreenPlayableActivity.this.onLayoutStateChange(newLayoutInfo);
});
}
}
}
37 changes: 0 additions & 37 deletions Assets/Scenes/0.OriginalScene/Original.asset

This file was deleted.

Loading