optimized for mobile

main
Benjamin Kraft 1 year ago
parent 7467616884
commit d1e9de7cf3
  1. 2
      Assets/RenderAssets/URP Asset Renderer.asset
  2. 2
      Assets/RenderAssets/URP Asset.asset
  3. 18
      Assets/Scripts/Dimensions.cs
  4. 10
      Assets/Scripts/Dimensions.cs.meta
  5. 4
      Assets/Scripts/Game/GameManager.cs
  6. 9
      Assets/Scripts/Game/Player.cs
  7. 29
      Assets/Scripts/GameUI.cs
  8. 4
      Assets/UI Toolkit/PlayerUI.uxml
  9. 2
      Assets/UI Toolkit/game.uss
  10. 36
      Assets/UI Toolkit/player_panel.uss
  11. 2
      Packages/manifest.json
  12. 99
      Packages/packages-lock.json
  13. 12
      ProjectSettings/ProjectSettings.asset

@ -34,7 +34,7 @@ MonoBehaviour:
- name: Additive with Mask - name: Additive with Mask
maskTextureChannel: 1 maskTextureChannel: 1
blendMode: 0 blendMode: 0
m_UseDepthStencilBuffer: 1 m_UseDepthStencilBuffer: 0
m_UseCameraSortingLayersTexture: 0 m_UseCameraSortingLayersTexture: 0
m_CameraSortingLayersTextureBound: -1 m_CameraSortingLayersTextureBound: -1
m_CameraSortingLayerDownsamplingMethod: 0 m_CameraSortingLayerDownsamplingMethod: 0

@ -61,7 +61,7 @@ MonoBehaviour:
m_MixedLightingSupported: 1 m_MixedLightingSupported: 1
m_SupportsLightLayers: 0 m_SupportsLightLayers: 0
m_DebugLevel: 0 m_DebugLevel: 0
m_UseAdaptivePerformance: 1 m_UseAdaptivePerformance: 0
m_ColorGradingMode: 0 m_ColorGradingMode: 0
m_ColorGradingLutSize: 32 m_ColorGradingLutSize: 32
m_UseFastSRGBLinearConversion: 0 m_UseFastSRGBLinearConversion: 0

@ -1,7 +1,6 @@
using System; using System;
using UnityEngine; using UnityEngine;
[ExecuteInEditMode]
public class Dimensions : MonoBehaviour { public class Dimensions : MonoBehaviour {
[Tooltip("How much height for player panels")] [Tooltip("How much height for player panels")]
public float panelHeightPercentage; public float panelHeightPercentage;
@ -18,8 +17,18 @@ public class Dimensions : MonoBehaviour {
public SpriteRenderer background; public SpriteRenderer background;
public static Dimensions Singleton; public static Dimensions Singleton;
private void OnEnable() { private void Awake() {
Singleton = this; Singleton = this;
GetComponents();
}
private void OnValidate() {
GetComponents();
}
private void GetComponents() {
topL = topC.GetComponent<LineRenderer>();
bottomL = bottomC.GetComponent<LineRenderer>();
} }
public float top, bottom, left, right; public float top, bottom, left, right;
@ -30,11 +39,6 @@ public class Dimensions : MonoBehaviour {
private LineRenderer topL, bottomL; private LineRenderer topL, bottomL;
private void OnValidate() {
topL = topC.GetComponent<LineRenderer>();
bottomL = bottomC.GetComponent<LineRenderer>();
}
private void Update() { private void Update() {
float height = mainCamera.orthographicSize * 2; float height = mainCamera.orthographicSize * 2;
float panelHeight = height * panelHeightPercentage / 100f; float panelHeight = height * panelHeightPercentage / 100f;

@ -1,3 +1,11 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 572c5b8dd6a94b3585befaa50a883755 guid: 572c5b8dd6a94b3585befaa50a883755
timeCreated: 1680781703 MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: -10
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

@ -16,6 +16,10 @@ namespace Game {
private void OnEnable() { private void OnEnable() {
Singleton = this; Singleton = this;
// Move this to settings
Application.targetFrameRate = 144;
QualitySettings.vSyncCount = 0;
} }
public Object ballPrefab; public Object ballPrefab;

@ -1,14 +1,9 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Transactions;
using Unity.Netcode; using Unity.Netcode;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using UnityEngine.Serialization;
using UnityEngine.UIElements; using UnityEngine.UIElements;
namespace Game { namespace Game {
@ -42,8 +37,8 @@ namespace Game {
} }
// Unit distance from zero // Unit distance from zero
private readonly float baseBorder = Dimensions.Singleton.Width / 2 * 0.8f; private readonly float baseBorder = Dimensions.Singleton.Width / 2 * 0.9f;
private readonly float borderSummand = Dimensions.Singleton.Width / 2 * 0.2f; private readonly float borderSummand = Dimensions.Singleton.Width / 2 * 0.1f;
protected float Border { protected float Border {
get { get {
return Mathf.Min(Modifications.Where(m => m.Properties.effect == ModEffect.Border) return Mathf.Min(Modifications.Where(m => m.Properties.effect == ModEffect.Border)

@ -2,9 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Game; using Game;
using UnityEditor.UIElements;
using UnityEngine; using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.UIElements; using UnityEngine.UIElements;
public class GameUI : MonoBehaviour { public class GameUI : MonoBehaviour {
@ -52,24 +50,25 @@ public class GameUI : MonoBehaviour {
float heightPercentage = Dimensions.Singleton.panelHeightPercentage; float heightPercentage = Dimensions.Singleton.panelHeightPercentage;
PlayerPanel(Side.Top).style.height = PlayerPanel(Side.Bottom).style.height = Length.Percent(heightPercentage); PlayerPanel(Side.Top).style.height = PlayerPanel(Side.Bottom).style.height = Length.Percent(heightPercentage);
SetupButtons(Side.Top); SetupGoButton(Side.Top, "left");
SetupButtons(Side.Bottom); SetupGoButton(Side.Top, "right");
SetupGoButton(Side.Bottom, "left");
SetupGoButton(Side.Bottom, "right");
} }
public delegate void ButtonDown(Side side, string direction); public delegate void ButtonDown(Side verticalSide, string horizontalSide);
public delegate void ButtonUp(Side side, string direction); public delegate void ButtonUp(Side side, string direction);
public ButtonDown buttonDown; public ButtonDown buttonDown;
public ButtonUp buttonUp; public ButtonUp buttonUp;
private void SetupButtons(Side side) { private Label GetGoButton(Side sideVertical, string sideHorizontal) {
Button btnLeft = PlayerPanel(side).Q<Button>("btn_left"); return PlayerPanel(sideVertical).Q<Label>("go_" + sideHorizontal);
btnLeft.clickable.activators.Clear(); }
btnLeft.RegisterCallback<MouseDownEvent>(_ => buttonDown(side, "left"));
btnLeft.RegisterCallback<MouseUpEvent>(_ => buttonUp(side, "left")); private void SetupGoButton(Side sideVertical, string sideHorizontal) {
var element = GetGoButton(sideVertical, sideHorizontal);
Button btnRight = PlayerPanel(side).Q<Button>("btn_right"); element.RegisterCallback<PointerDownEvent>(_ => buttonDown(sideVertical, sideHorizontal));
btnRight.clickable.activators.Clear(); element.RegisterCallback<PointerUpEvent>(_ => buttonUp(sideVertical, sideHorizontal));
btnRight.RegisterCallback<MouseDownEvent>(_ => buttonDown(side, "right")); element.RegisterCallback<PointerLeaveEvent>(_ => buttonUp(sideVertical, sideHorizontal));
btnRight.RegisterCallback<MouseUpEvent>(_ => buttonUp(side, "right"));
} }
} }

@ -1,9 +1,9 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/UI%20Toolkit/styles.uss?fileID=7433441132597879392&amp;guid=a6abab2f6d20ba823bad41d2081810e9&amp;type=3#styles" /> <Style src="project://database/Assets/UI%20Toolkit/styles.uss?fileID=7433441132597879392&amp;guid=a6abab2f6d20ba823bad41d2081810e9&amp;type=3#styles" />
<Style src="project://database/Assets/UI%20Toolkit/player_panel.uss?fileID=7433441132597879392&amp;guid=102b2cb1b84d8883abde9356b92d807e&amp;type=3#player_panel" /> <Style src="project://database/Assets/UI%20Toolkit/player_panel.uss?fileID=7433441132597879392&amp;guid=102b2cb1b84d8883abde9356b92d807e&amp;type=3#player_panel" />
<ui:Button display-tooltip-when-elided="true" name="btn_left" text="←" /> <ui:Label text="←" display-tooltip-when-elided="true" name="go_left" class="go" />
<ui:VisualElement class="mods_list" /> <ui:VisualElement class="mods_list" />
<ui:Label display-tooltip-when-elided="true" name="score" binding-path="m_Score" /> <ui:Label display-tooltip-when-elided="true" name="score" binding-path="m_Score" />
<ui:VisualElement class="mods_list" /> <ui:VisualElement class="mods_list" />
<ui:Button display-tooltip-when-elided="true" name="btn_right" text="→" /> <ui:Label text="→" display-tooltip-when-elided="true" name="go_right" class="go" />
</ui:UXML> </ui:UXML>

@ -2,6 +2,6 @@
width: 100%; width: 100%;
position: absolute; position: absolute;
flex-direction: row; flex-direction: row;
align-items: center; align-items: stretch;
justify-content: space-between; justify-content: space-between;
} }

@ -1,8 +1,26 @@
Button { .go {
flex-grow: 0; flex-shrink: 1;
height: auto; width: auto;
width: 50px; font-size: 50px;
font-size: 30px; -unity-text-align: middle-center;
border-left-color: rgb(141, 157, 255);
border-right-color: rgb(141, 157, 255);
border-top-color: rgb(141, 157, 255);
border-bottom-color: rgb(141, 157, 255);
border-left-width: 3px;
border-right-width: 3px;
border-top-width: 3px;
border-bottom-width: 3px;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
margin-left: 10px;
margin-right: 10px;
margin-top: 10px;
margin-bottom: 10px;
background-color: rgba(91, 91, 91, 255);
flex-grow: 1;
} }
.mods_list { .mods_list {
@ -23,10 +41,16 @@ Button {
.mods_list > VisualElement { .mods_list > VisualElement {
width: 100%; width: 100%;
flex-grow: 1; flex-grow: 1;
background-image: url('project://database/Packages/com.unity.2d.sprite/Editor/ObjectMenuCreation/DefaultAssets/Textures/HexagonFlat-Top.png?fileID=2747690628134850419&guid=16037dbd798344f57a526d53d48f5ead&type=3#Hexagon Flat-Top');
-unity-background-scale-mode: scale-to-fit; -unity-background-scale-mode: scale-to-fit;
margin-right: 0; margin-right: 0;
margin-bottom: 5px; margin-bottom: 5px;
margin-top: 5px; margin-top: 5px;
max-height: 50%; max-height: 50%;
} }
.go:hover {
border-left-color: rgba(64, 72, 255, 255);
border-right-color: rgba(64, 72, 255, 255);
border-top-color: rgba(64, 72, 255, 255);
border-bottom-color: rgba(64, 72, 255, 255);
}

@ -2,7 +2,6 @@
"dependencies": { "dependencies": {
"com.unity.adaptiveperformance.samsung.android": "4.0.2", "com.unity.adaptiveperformance.samsung.android": "4.0.2",
"com.unity.collab-proxy": "2.0.0", "com.unity.collab-proxy": "2.0.0",
"com.unity.feature.2d": "1.0.0",
"com.unity.feature.mobile": "1.0.0", "com.unity.feature.mobile": "1.0.0",
"com.unity.ide.rider": "3.0.18", "com.unity.ide.rider": "3.0.18",
"com.unity.ide.visualstudio": "2.0.17", "com.unity.ide.visualstudio": "2.0.17",
@ -33,7 +32,6 @@
"com.unity.modules.terrainphysics": "1.0.0", "com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0", "com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0", "com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0", "com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0", "com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0",

@ -1,90 +1,5 @@
{ {
"dependencies": { "dependencies": {
"com.unity.2d.animation": {
"version": "7.0.9",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.2d.common": "6.0.6",
"com.unity.2d.sprite": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.uielements": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.2d.common": {
"version": "6.0.6",
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.mathematics": "1.1.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.burst": "1.5.1"
},
"url": "https://packages.unity.com"
},
"com.unity.2d.path": {
"version": "5.0.2",
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.2d.pixel-perfect": {
"version": "5.0.3",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.2d.psdimporter": {
"version": "6.0.7",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.2d.animation": "7.0.9",
"com.unity.2d.common": "6.0.6",
"com.unity.2d.sprite": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.2d.sprite": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {}
},
"com.unity.2d.spriteshape": {
"version": "7.0.6",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.mathematics": "1.1.0",
"com.unity.2d.common": "6.0.4",
"com.unity.2d.path": "5.0.2",
"com.unity.modules.physics2d": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.2d.tilemap": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {}
},
"com.unity.2d.tilemap.extras": {
"version": "2.2.4",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.modules.tilemap": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.ugui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.adaptiveperformance": { "com.unity.adaptiveperformance": {
"version": "4.0.1", "version": "4.0.1",
"depth": 1, "depth": 1,
@ -137,20 +52,6 @@
"dependencies": {}, "dependencies": {},
"url": "https://packages.unity.com" "url": "https://packages.unity.com"
}, },
"com.unity.feature.2d": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.2d.animation": "7.0.9",
"com.unity.2d.pixel-perfect": "5.0.3",
"com.unity.2d.psdimporter": "6.0.7",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.spriteshape": "7.0.6",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.2d.tilemap.extras": "2.2.4"
}
},
"com.unity.feature.mobile": { "com.unity.feature.mobile": {
"version": "1.0.0", "version": "1.0.0",
"depth": 0, "depth": 0,

@ -167,15 +167,15 @@ PlayerSettings:
iPhone: 0 iPhone: 0
tvOS: 0 tvOS: 0
overrideDefaultApplicationIdentifier: 0 overrideDefaultApplicationIdentifier: 0
AndroidBundleVersionCode: 3 AndroidBundleVersionCode: 4
AndroidMinSdkVersion: 22 AndroidMinSdkVersion: 22
AndroidTargetSdkVersion: 0 AndroidTargetSdkVersion: 33
AndroidPreferredInstallLocation: 1 AndroidPreferredInstallLocation: 1
aotOptions: aotOptions:
stripEngineCode: 1 stripEngineCode: 1
iPhoneStrippingLevel: 0 iPhoneStrippingLevel: 0
iPhoneScriptCallOptimization: 0 iPhoneScriptCallOptimization: 0
ForceInternetPermission: 0 ForceInternetPermission: 1
ForceSDCardPermission: 0 ForceSDCardPermission: 0
CreateWallpaper: 0 CreateWallpaper: 0
APKExpansionFiles: 0 APKExpansionFiles: 0
@ -677,8 +677,10 @@ PlayerSettings:
platformArchitecture: {} platformArchitecture: {}
scriptingBackend: scriptingBackend:
Android: 1 Android: 1
il2cppCompilerConfiguration: {} il2cppCompilerConfiguration:
managedStrippingLevel: {} Android: 2
managedStrippingLevel:
Android: 3
incrementalIl2cppBuild: {} incrementalIl2cppBuild: {}
suppressCommonWarnings: 1 suppressCommonWarnings: 1
allowUnsafeCode: 0 allowUnsafeCode: 0

Loading…
Cancel
Save