Explorar el Código

Start test med Android. Start med login script

Axel Nordh hace 7 años
padre
commit
0355dee9bb

+ 39 - 7
Assets/Prefab/QuestionCard.prefab

@@ -135,9 +135,9 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   m_IgnoreLayout: 0
   m_MinWidth: -1
-  m_MinHeight: -1
+  m_MinHeight: 150
   m_PreferredWidth: 100
-  m_PreferredHeight: 180
+  m_PreferredHeight: 200
   m_FlexibleWidth: 0
   m_FlexibleHeight: 1
   m_LayoutPriority: 1
@@ -190,8 +190,8 @@ RectTransform:
   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.00071561}
-  m_SizeDelta: {x: 90, y: 125.3}
+  m_AnchoredPosition: {x: 0, y: -0.000019491}
+  m_SizeDelta: {x: 88, y: 123.53}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!222 &7378609231691140005
 CanvasRenderer:
@@ -227,8 +227,8 @@ MonoBehaviour:
     m_FontStyle: 0
     m_BestFit: 1
     m_MinSize: 10
-    m_MaxSize: 255
-    m_Alignment: 1
+    m_MaxSize: 18
+    m_Alignment: 4
     m_AlignByGeometry: 0
     m_RichText: 1
     m_HorizontalOverflow: 0
@@ -247,6 +247,7 @@ GameObject:
   - component: {fileID: 1876947779286866796}
   - component: {fileID: 5401332201340434537}
   - component: {fileID: 4370785109706722973}
+  - component: {fileID: 736746258721576424}
   m_Layer: 5
   m_Name: QuestionPanel
   m_TagString: Untagged
@@ -295,7 +296,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 0.6698113, g: 0.6698113, b: 0.6698113, a: 1}
+  m_Color: {r: 0.88235295, g: 0.88235295, b: 0.88235295, a: 1}
   m_RaycastTarget: 1
   m_OnCullStateChanged:
     m_PersistentCalls:
@@ -331,6 +332,21 @@ MonoBehaviour:
   m_FlexibleWidth: -1
   m_FlexibleHeight: 1
   m_LayoutPriority: 1
+--- !u!114 &736746258721576424
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6413417402222877887}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5}
+  m_EffectDistance: {x: 1, y: -1}
+  m_UseGraphicAlpha: 1
 --- !u!1 &8520071005363342146
 GameObject:
   m_ObjectHideFlags: 0
@@ -422,6 +438,7 @@ GameObject:
   - component: {fileID: 7921554056996791670}
   - component: {fileID: 8825294032478541024}
   - component: {fileID: 5992339406224358287}
+  - component: {fileID: 675644889844183679}
   m_Layer: 5
   m_Name: YearPanel
   m_TagString: Untagged
@@ -506,3 +523,18 @@ MonoBehaviour:
   m_FlexibleWidth: -1
   m_FlexibleHeight: -1
   m_LayoutPriority: 1
+--- !u!114 &675644889844183679
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8861552641027936267}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 1573420865, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5}
+  m_EffectDistance: {x: 1, y: -1}
+  m_UseGraphicAlpha: 1

+ 50 - 10
Assets/Scripts/Login/Login.cs

@@ -1,21 +1,61 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.Networking;
+using UnityEngine.UI;
 
-public class Login : MonoBehaviour
-{
+public class Login : MonoBehaviour {
 
     public GameObject username;
     public GameObject password;
-    // Start is called before the first frame update
-    void Start()
-    {
-        
+
+    public Button loginButton;
+
+    public Text errorText;
+
+    private string Username;
+    private string Password;
+    private string loginUrl = "http://nordh.xyz/narKampen/dbFiles/Login.php?";
+
+    private void Start() {
+        loginButton.onClick.AddListener(loginAction);
+    }
+
+    private void Update() {
+        Username = username.GetComponent<InputField>().text;
+        Password = password.GetComponent<InputField>().text;
+    }
+
+    void loginAction() {
+        string errorMessage = "";
+        if (Username == "") {
+            errorMessage = "Username is required";
+        }
+        if (Password == "") {
+            if (errorMessage != "") {
+                errorMessage += "\n";
+            }
+            errorMessage += "Password is required";
+        }
+        Color errorColor = errorText.color;
+        if (errorMessage == "") {
+            errorColor.a = 0;
+            StartCoroutine(loginCall());
+        } else {
+            errorText.text = errorMessage;
+            errorColor.a = 1;
+        }
+        errorText.color = errorColor;
     }
 
-    // Update is called once per frame
-    void Update()
-    {
-        
+    IEnumerator loginCall() {
+        string postUrl = loginUrl + "name=" + UnityWebRequest.EscapeURL(Username) + "&password=" + UnityWebRequest.EscapeURL(Password);
+
+        UnityWebRequest www = UnityWebRequest.Get(postUrl);
+        yield return www.SendWebRequest();
+
+        if (www.error != null) {
+            errorText.text = "There was an error logging in " + www.error;
+        }
     }
 }

+ 2 - 4
Assets/Scripts/Login/Register.cs

@@ -1,7 +1,5 @@
 using System.Collections;
-using System.Collections.Generic;
 using UnityEngine;
-using System.Text.RegularExpressions;
 using UnityEngine.UI;
 using UnityEngine.Networking;
 
@@ -58,7 +56,6 @@ public class Register : MonoBehaviour {
             errorColor.a = 0;
 
             StartCoroutine(RegisterUser());
-
         }
         errorText.color = errorColor;
     }
@@ -66,10 +63,11 @@ public class Register : MonoBehaviour {
     IEnumerator RegisterUser() {
         // register user at server, check for already in use for username and email.
         // TODO - hash+salt password
+        BCrypt.Net.BCrypt
         string postUrl = registerUserUrl + "name=" + UnityWebRequest.EscapeURL(Username) + "&password=" + UnityWebRequest.EscapeURL(Password) + "&email=" + UnityWebRequest.EscapeURL(Email);
 
         UnityWebRequest www = UnityWebRequest.Get(postUrl);
-        yield return www;
+        yield return www.SendWebRequest();
 
         if (www.error != null) {
             errorText.text = "There was an error registering this user, try again later";

+ 82 - 12
Assets/narKampen.unity

@@ -951,7 +951,7 @@ MonoBehaviour:
     m_FontStyle: 0
     m_BestFit: 1
     m_MinSize: 10
-    m_MaxSize: 40
+    m_MaxSize: 14
     m_Alignment: 3
     m_AlignByGeometry: 0
     m_RichText: 1
@@ -1513,7 +1513,7 @@ MonoBehaviour:
     m_FontStyle: 0
     m_BestFit: 1
     m_MinSize: 10
-    m_MaxSize: 40
+    m_MaxSize: 14
     m_Alignment: 3
     m_AlignByGeometry: 0
     m_RichText: 1
@@ -2477,7 +2477,7 @@ MonoBehaviour:
   m_ChildForceExpandWidth: 0
   m_ChildForceExpandHeight: 1
   m_ChildControlWidth: 0
-  m_ChildControlHeight: 1
+  m_ChildControlHeight: 0
 --- !u!114 &1423700018 stripped
 MonoBehaviour:
   m_CorrespondingSourceObject: {fileID: 4606992419449489139, guid: 952f6c50eed555c448854a8a8fdb799e,
@@ -2803,10 +2803,10 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Padding:
-    m_Left: 0
-    m_Right: 0
-    m_Top: 0
-    m_Bottom: 0
+    m_Left: 4
+    m_Right: 4
+    m_Top: 4
+    m_Bottom: 4
   m_ChildAlignment: 0
   m_Spacing: 2
   m_ChildForceExpandWidth: 1
@@ -3017,7 +3017,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 1, y: 1}
-  m_AnchoredPosition: {x: 0.000009535399, y: 0}
+  m_AnchoredPosition: {x: -0.000020123134, y: 0}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0, y: 1}
 --- !u!114 &1715970008
@@ -3055,7 +3055,7 @@ MonoBehaviour:
   m_StartCorner: 0
   m_StartAxis: 0
   m_CellSize: {x: 100, y: 200}
-  m_Spacing: {x: 5, y: 0}
+  m_Spacing: {x: 3, y: 0}
   m_Constraint: 2
   m_ConstraintCount: 1
 --- !u!114 &1715970010
@@ -3347,7 +3347,7 @@ PrefabInstance:
     - target: {fileID: 1781451649244772801, guid: e91b5c1a341f8be469b7bab25ee954d7,
         type: 3}
       propertyPath: m_SizeDelta.y
-      value: 0
+      value: 200
       objectReference: {fileID: 0}
     - target: {fileID: 1781451649244772801, guid: e91b5c1a341f8be469b7bab25ee954d7,
         type: 3}
@@ -3398,11 +3398,21 @@ PrefabInstance:
         type: 3}
       propertyPath: parent
       value: 
-      objectReference: {fileID: 1715970007}
+      objectReference: {fileID: 0}
+    - target: {fileID: 7933561225938041952, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: placeholderParent
+      value: 
+      objectReference: {fileID: 0}
     - target: {fileID: 3652310416093541855, guid: e91b5c1a341f8be469b7bab25ee954d7,
         type: 3}
       propertyPath: m_PreferredHeight
-      value: 180
+      value: 200
+      objectReference: {fileID: 0}
+    - target: {fileID: 3652310416093541855, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_MinHeight
+      value: 150
       objectReference: {fileID: 0}
     - target: {fileID: 4763204001755850318, guid: e91b5c1a341f8be469b7bab25ee954d7,
         type: 3}
@@ -3459,6 +3469,66 @@ PrefabInstance:
       propertyPath: m_SizeDelta.y
       value: 0
       objectReference: {fileID: 0}
+    - target: {fileID: 4303414690502663021, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.r
+      value: 0.254717
+      objectReference: {fileID: 0}
+    - target: {fileID: 4303414690502663021, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.g
+      value: 0.254717
+      objectReference: {fileID: 0}
+    - target: {fileID: 4303414690502663021, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.b
+      value: 0.254717
+      objectReference: {fileID: 0}
+    - target: {fileID: 4303414690502663021, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.a
+      value: 0.78431374
+      objectReference: {fileID: 0}
+    - target: {fileID: 5145380995516278111, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.a
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 5145380995516278111, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.r
+      value: 0.88235295
+      objectReference: {fileID: 0}
+    - target: {fileID: 5145380995516278111, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.g
+      value: 0.88235295
+      objectReference: {fileID: 0}
+    - target: {fileID: 5145380995516278111, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.b
+      value: 0.88235295
+      objectReference: {fileID: 0}
+    - target: {fileID: 5145380996076868371, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.r
+      value: 0.78431374
+      objectReference: {fileID: 0}
+    - target: {fileID: 5145380996076868371, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.g
+      value: 0.78431374
+      objectReference: {fileID: 0}
+    - target: {fileID: 5145380996076868371, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.b
+      value: 0.78431374
+      objectReference: {fileID: 0}
+    - target: {fileID: 5145380996076868371, guid: e91b5c1a341f8be469b7bab25ee954d7,
+        type: 3}
+      propertyPath: m_Color.a
+      value: 1
+      objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: e91b5c1a341f8be469b7bab25ee954d7, type: 3}
 --- !u!1 &1956041112

+ 5 - 1
ProjectSettings/EditorBuildSettings.asset

@@ -4,4 +4,8 @@
 EditorBuildSettings:
   m_ObjectHideFlags: 0
   serializedVersion: 2
-  m_Scenes: []
+  m_Scenes:
+  - enabled: 1
+    path: Assets/narKampen.unity
+    guid: 173419871896d2742a84e462fa3af7df
+  m_configObjects: {}

+ 3 - 0
ProjectSettings/GraphicsSettings.asset

@@ -35,6 +35,9 @@ GraphicsSettings:
   - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
   - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
   - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
+  - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
+  - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
+  - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
   m_PreloadedShaders: []
   m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
     type: 0}

+ 104 - 5
ProjectSettings/ProjectSettings.asset

@@ -12,8 +12,8 @@ PlayerSettings:
   targetDevice: 2
   useOnDemandResources: 0
   accelerometerFrequency: 60
-  companyName: DefaultCompany
-  productName: "N\xE4r Kampen"
+  companyName: AxelNordh
+  productName: NarKampen
   defaultCursor: {fileID: 0}
   cursorHotspot: {x: 0, y: 0}
   m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
@@ -106,6 +106,11 @@ PlayerSettings:
   xboxOneDisableEsram: 0
   xboxOnePresentImmediateThreshold: 0
   switchQueueCommandMemory: 0
+  switchQueueControlMemory: 16384
+  switchQueueComputeMemory: 262144
+  switchNVNShaderPoolsGranularity: 33554432
+  switchNVNDefaultPoolsGranularity: 16777216
+  switchNVNOtherPoolsGranularity: 16777216
   vulkanEnableSetSRGBWrite: 0
   m_SupportedAspectRatios:
     4:3: 1
@@ -113,7 +118,7 @@ PlayerSettings:
     16:10: 1
     16:9: 1
     Others: 1
-  bundleVersion: 1.0
+  bundleVersion: 0.1
   preloadedAssets: []
   metroInputSource: 0
   wsaTransparentSwapchain: 0
@@ -147,7 +152,8 @@ PlayerSettings:
   resolutionScalingMode: 0
   androidSupportedAspectRatio: 1
   androidMaxAspectRatio: 2.1
-  applicationIdentifier: {}
+  applicationIdentifier:
+    Android: se.axelnordh.narkampen
   buildNumber: {}
   AndroidBundleVersionCode: 1
   AndroidMinSdkVersion: 16
@@ -252,7 +258,99 @@ PlayerSettings:
   androidGamepadSupportLevel: 0
   resolutionDialogBanner: {fileID: 0}
   m_BuildTargetIcons: []
-  m_BuildTargetPlatformIcons: []
+  m_BuildTargetPlatformIcons:
+  - m_BuildTarget: Android
+    m_Icons:
+    - m_Textures: []
+      m_Width: 432
+      m_Height: 432
+      m_Kind: 2
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 324
+      m_Height: 324
+      m_Kind: 2
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 216
+      m_Height: 216
+      m_Kind: 2
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 162
+      m_Height: 162
+      m_Kind: 2
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 108
+      m_Height: 108
+      m_Kind: 2
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 81
+      m_Height: 81
+      m_Kind: 2
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 192
+      m_Height: 192
+      m_Kind: 1
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 144
+      m_Height: 144
+      m_Kind: 1
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 96
+      m_Height: 96
+      m_Kind: 1
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 72
+      m_Height: 72
+      m_Kind: 1
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 48
+      m_Height: 48
+      m_Kind: 1
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 36
+      m_Height: 36
+      m_Kind: 1
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 192
+      m_Height: 192
+      m_Kind: 0
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 144
+      m_Height: 144
+      m_Kind: 0
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 96
+      m_Height: 96
+      m_Kind: 0
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 72
+      m_Height: 72
+      m_Kind: 0
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 48
+      m_Height: 48
+      m_Kind: 0
+      m_SubKind: 
+    - m_Textures: []
+      m_Width: 36
+      m_Height: 36
+      m_Kind: 0
+      m_SubKind: 
   m_BuildTargetBatching: []
   m_BuildTargetGraphicsAPIs: []
   m_BuildTargetVRSettings: []
@@ -393,6 +491,7 @@ PlayerSettings:
   switchAllowsRuntimeAddOnContentInstall: 0
   switchDataLossConfirmation: 0
   switchUserAccountLockEnabled: 0
+  switchSystemResourceMemory: 16777216
   switchSupportedNpadStyles: 3
   switchNativeFsCacheSize: 32
   switchIsHoldTypeHorizontal: 0

+ 11 - 0
app.config

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.3.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+</configuration>

+ 30 - 0
dbFiles/Login.php

@@ -0,0 +1,30 @@
+<?php
+	$hostname = 'localhost';
+	$username = 'narKampen';
+	$pass = 'narKampenPassword';
+	$database = 'narKampen';
+	
+	$conn = new mysqli($hostname, $username, $pass, $database);
+	if (!$conn) {
+		die("Connection Failed. ". mysqli_connect_error());
+	}
+	mysqli_set_charset($conn,'utf8');
+	
+	$username = $conn->real_escape_string($_GET['name']);
+	$password = $conn->real_escape_string($_GET['password']);
+	
+	if ($newUsername == '' || $newPassword == '') {
+		echo "Supply values for all required fields";
+		return;
+	}
+	
+	$sql = "SELECT id FROM users WHERE username = '$username' AND password = '$password'";
+	$result = $conn->query($sql);
+	if ($result->mysqli_num_rows == 1) {
+		echo "Success";
+	} else {
+		echo "Error while logging in user " . $conn->error;
+	}
+	$conn->close();
+	
+?>

+ 1 - 1
dbFiles/Register.php

@@ -21,7 +21,7 @@
 	
 	$sql = "INSERT INTO users (username, password, email) VALUES ('$newUsername', '$newPassword', '$newEmail')";
 	if ($conn->query($sql) === true) {
-		
+		echo "Success";
 	} else {
 		echo "Error while registering new user " . $conn->error;
 	}