Continue work on spelling bee

This commit is contained in:
lvrossem
2023-03-01 17:19:32 +01:00
parent 5652259e4e
commit 9cdcb63baf
4 changed files with 121 additions and 17 deletions

View File

@@ -6,7 +6,7 @@ TextureImporter:
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
@@ -36,13 +36,13 @@ TextureImporter:
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
@@ -51,9 +51,9 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
@@ -119,7 +119,7 @@ TextureImporter:
outline: []
physicsShape: []
bones: []
spriteID:
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:

View File

@@ -6,7 +6,7 @@ TextureImporter:
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
@@ -36,13 +36,13 @@ TextureImporter:
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
@@ -51,9 +51,9 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
@@ -119,7 +119,7 @@ TextureImporter:
outline: []
physicsShape: []
bones: []
spriteID:
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:

View File

@@ -530,6 +530,82 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1338727890
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1338727893}
- component: {fileID: 1338727892}
- component: {fileID: 1338727891}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1338727891
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1338727890}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 70fe6b4afbc13054a9ee05f5112229c2, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1338727892
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1338727890}
m_CullTransparentMesh: 1
--- !u!224 &1338727893
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1338727890}
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1768150806}
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: -26, y: 31}
m_SizeDelta: {x: 300.354, y: 272.6454}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1355716508
GameObject:
m_ObjectHideFlags: 0
@@ -759,6 +835,7 @@ RectTransform:
m_Children:
- {fileID: 906197777}
- {fileID: 1355716509}
- {fileID: 1338727893}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -779,3 +856,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 44fbed5ae228de39b9f727def7578d06, type: 3}
m_Name:
m_EditorClassIdentifier:
image: {fileID: 1338727891}

View File

@@ -2,23 +2,49 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
public class SpellingBeeController : MonoBehaviour
{
private string[] words;
public Image image;
// Start is called before the first frame update
void Start() {
TextAsset textFile = Resources.Load<TextAsset>("SpellingBee/words");
string fileContents = textFile.text;
words = fileContents.Split('\n');
words = fileContents.Split('\n');
Image imageComponent = image.GetComponent<Image>();
// Load the new sprite from the Resources folder
Debug.Log("SpellingBee/images/" + "monke");
Sprite sprite = Resources.Load<Sprite>("SpellingBee/images/monke");
image.sprite = sprite;
Debug.Log(sprite.pixelsPerUnit);
//changeSprite("monke");
}
// Update is called once per frame
void Update() {
int randomIndex = UnityEngine.Random.Range(0, words.Length - 1);
string randomWord = words[randomIndex];
changeSprite(randomWord);
Debug.Log(randomWord);
}
void changeSprite(string spriteName) {
Image imageComponent = image.GetComponent<Image>();
// Load the new sprite from the Resources folder
Debug.Log("SpellingBee/images/" + spriteName);
Sprite sprite = Resources.Load<Sprite>("SpellingBee/images/" + spriteName);
Debug.Log(sprite.pixelsPerUnit);
// Set the new sprite as the Image component's source image
image.sprite = sprite;
}
}