diff --git a/Assets/InventoryStuff/DisplayScrolls.cs b/Assets/InventoryStuff/DisplayScrolls.cs index 7cdb17e2a552187e7a51931f98a3ba5e64dabf0b..553c37bf6f32b23a93a37ecfa05ebf27e896ae20 100644 --- a/Assets/InventoryStuff/DisplayScrolls.cs +++ b/Assets/InventoryStuff/DisplayScrolls.cs @@ -3,10 +3,12 @@ using System.IO; using UnityEngine; using UnityEngine.UI; +using TMPro; public class DisplayScrolls : MonoBehaviour { - public List<Scroll> scrolls = new List<Scroll>(); + public Scroll[] scrolls; + public GameObject ScrollPrefab; @@ -42,15 +44,31 @@ public Vector3 GetPosition(int i) return new Vector3(x_Start+ (X_Pacece_Between_Items * (i % number_of_Column)), y_Start + (-y_Pacece_Between_Items * (i / number_of_Column)), 0f); } + [System.Serializable] + class ScrollArrayWrapper{ + public Scroll[] scrolls; + }; + // Start is called before the first frame update void Start() { + //get Scrolls from Backend; + //TODO REST-Call instead of Json-File string path = "Mock-Scrolls.json"; string jsonString = File.ReadAllText(path); jsonString = jsonString.Replace(System.Environment.NewLine, ""); - jsonString = jsonString.Replace("\t", ""); - Debug.Log(jsonString); - Scroll[] scrollsRead = JsonUtility.FromJson<Scroll[]>(jsonString); - //this.scrolls = scrollsRead; + jsonString = jsonString.Replace("\t", ""); + + ScrollArrayWrapper scrollsRead = new ScrollArrayWrapper(); + scrollsRead = (ScrollArrayWrapper)JsonUtility.FromJson(jsonString, scrollsRead.GetType()); + this.scrolls = scrollsRead.scrolls; + + //Build Selection-GUI of Scrolls + for (int i = 0; i < this.scrolls.Length; i++) { + var obj = Instantiate(ScrollPrefab, Vector3.zero, Quaternion.identity, transform); + obj.GetComponent<RectTransform>().localPosition = GetPosition(i); + obj.GetComponent<ScrollClickedScript>().scroll = this.scrolls[i]; + obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = this.scrolls[i].label; + } } } diff --git a/Assets/Resources/Prefabs/ScrollDisplay.prefab b/Assets/Resources/Prefabs/ScrollDisplay.prefab index ef208dca69240eacb8189f33a7b1927608b68907..35419095bd2a85196d8a6fdaf39ba30d81899159 100644 --- a/Assets/Resources/Prefabs/ScrollDisplay.prefab +++ b/Assets/Resources/Prefabs/ScrollDisplay.prefab @@ -11,6 +11,8 @@ GameObject: - component: {fileID: 659044494318708747} - component: {fileID: 3213819025273557502} - component: {fileID: 2305338954152611092} + - component: {fileID: 114452647229146242} + - component: {fileID: 114809707957640338} m_Layer: 5 m_Name: ScrollDisplay m_TagString: Untagged @@ -29,7 +31,7 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 3182838857086358575} + - {fileID: 5295466371659185427} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -73,7 +75,54 @@ MonoBehaviour: m_FillClockwise: 1 m_FillOrigin: 0 m_UseSpriteMesh: 0 ---- !u!1 &7738162277464361060 +--- !u!114 &114452647229146242 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3173330253721512196} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 11ddd9731d735dd47b5581d7f335747e, type: 3} + m_Name: + m_EditorClassIdentifier: + scroll: + problemTheory: + solutionTheory: + label: + description: + declarations: [] +--- !u!114 &114809707957640338 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3173330253721512196} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -1862395651, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Delegates: + - eventID: 4 + callback: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 114452647229146242} + m_MethodName: onClick + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + delegates: [] +--- !u!1 &5809183911047187526 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -81,23 +130,23 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 3182838857086358575} - - component: {fileID: 5561432925616113774} - - component: {fileID: 4926976350478616173} + - component: {fileID: 5295466371659185427} + - component: {fileID: 6923828144562967227} + - component: {fileID: 5867570113647991285} m_Layer: 5 - m_Name: Text + m_Name: Text (TMP) m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!224 &3182838857086358575 +--- !u!224 &5295466371659185427 RectTransform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7738162277464361060} + m_GameObject: {fileID: 5809183911047187526} 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} @@ -110,43 +159,121 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5561432925616113774 +--- !u!222 &6923828144562967227 CanvasRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7738162277464361060} + m_GameObject: {fileID: 5809183911047187526} m_CullTransparentMesh: 0 ---- !u!114 &4926976350478616173 +--- !u!114 &5867570113647991285 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7738162277464361060} + m_GameObject: {fileID: 5809183911047187526} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_Color: {r: 1, g: 1, b: 1, a: 1} m_RaycastTarget: 1 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: New Text + m_text: New Text + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4278190080 + m_fontColor: {r: 0, g: 0, b: 0, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_outlineColor: + serializedVersion: 2 + rgba: 4278190080 + m_fontSize: 44.1 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_textAlignment: 514 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_firstOverflowCharacterIndex: -1 + m_linkedTextComponent: {fileID: 0} + m_isLinkedTextComponent: 0 + m_isTextTruncated: 0 + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_ignoreRectMaskCulling: 0 + m_ignoreCulling: 1 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_VertexBufferAutoSizeReduction: 1 + m_firstVisibleCharacter: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_textInfo: + textComponent: {fileID: 5867570113647991285} + characterCount: 8 + spriteCount: 0 + spaceCount: 1 + wordCount: 2 + linkCount: 0 + lineCount: 2 + pageCount: 1 + materialCount: 1 + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_spriteAnimator: {fileID: 0} + m_hasFontAssetChanged: 0 + m_subTextObjects: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} diff --git a/Assets/ScrollClickedScript.cs b/Assets/ScrollClickedScript.cs new file mode 100644 index 0000000000000000000000000000000000000000..585fd7ad8bd0608626c603f025cdc5500d3d28e4 --- /dev/null +++ b/Assets/ScrollClickedScript.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ScrollClickedScript: MonoBehaviour +{ + public Scroll scroll; + + public void onClick() { + Debug.Log("clicked"); + } +} diff --git a/Assets/ScrollClickedScript.cs.meta b/Assets/ScrollClickedScript.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..d35108874a45adc453d1434db42fe00fff133aeb --- /dev/null +++ b/Assets/ScrollClickedScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 11ddd9731d735dd47b5581d7f335747e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/inventoryStuff.unity b/Assets/inventoryStuff.unity index 7a1c4af284035ed19787f6691638e837b9e3108d..695903b9511299432090d7b68f1b50ee5c6bbfda 100644 --- a/Assets/inventoryStuff.unity +++ b/Assets/inventoryStuff.unity @@ -205,7 +205,6 @@ RectTransform: - {fileID: 1181841652} - {fileID: 1243429077} - {fileID: 274389189} - - {fileID: 6421936590152144000} m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -265,8 +264,10 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: scrolls: [] - x_Start: -175 - y_Start: 0 + ScrollPrefab: {fileID: 3173330253721512196, guid: a6a9a3ebdb022e546a21d9f9ff148261, + type: 3} + x_Start: -240 + y_Start: 200 X_Pacece_Between_Items: 110 y_Pacece_Between_Items: 110 number_of_Column: 3 @@ -400,7 +401,8 @@ RectTransform: 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_Children: [] + m_Children: + - {fileID: 6421936590152144000} m_Father: {fileID: 249048815} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -795,7 +797,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 249048815} + m_TransformParent: {fileID: 1181841652} m_Modifications: - target: {fileID: 1410316395273548761, guid: efd7037a57100574780bb26bea0c0683, type: 3} @@ -820,17 +822,17 @@ PrefabInstance: - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} @@ -840,7 +842,7 @@ PrefabInstance: - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} propertyPath: m_RootOrder - value: 3 + value: 0 objectReference: {fileID: 0} - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} @@ -860,12 +862,12 @@ PrefabInstance: - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} propertyPath: m_AnchoredPosition.x - value: -660.0001 + value: -0.00012207031 objectReference: {fileID: 0} - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} propertyPath: m_AnchoredPosition.y - value: -253.04349 + value: 0.000045776367 objectReference: {fileID: 0} - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, type: 3} @@ -925,7 +927,7 @@ PrefabInstance: - target: {fileID: 2966758062926209900, guid: efd7037a57100574780bb26bea0c0683, type: 3} propertyPath: m_AnchoredPosition.y - value: 0.000032980104 + value: 0.00000961381 objectReference: {fileID: 0} - target: {fileID: 4536977264099877230, guid: efd7037a57100574780bb26bea0c0683, type: 3} diff --git a/Mock-Scrolls.json b/Mock-Scrolls.json index 9253e4b05e29f59764ac57064181beb1b94277bb..f681825c63791c836fb6720af9e7b6742a35dd03 100644 --- a/Mock-Scrolls.json +++ b/Mock-Scrolls.json @@ -1,7 +1,8 @@ -[ +{ + "scrolls": [ { "problemTheory": "bla", - "solutioTheory": "blubb", + "solutionTheory": "blubb", "label": "Pythagoras", "description": "a quadrat plus b quadrat ist c quadrat", "declarations": [ @@ -14,26 +15,22 @@ "name": "PointB", "type": "Point", "identifier": "URI" - } - , + }, { "name": "PointC", "type": "Point", "identifier": "URI" - } - , + }, { "name": "Distance AC", "type": "Distance", "identifier": "URI" - } - , + }, { "name": "Distance BC", "type": "Point", "identifier": "URI" - } - , + }, { "name": "Angle ACB", "type": "Angle", @@ -43,11 +40,11 @@ }, { "problemTheory": "bla", - "solutioTheory": "blubb", + "solutionTheory": "blubb", "label": "Tangens", "description": "Das standart Beispiel für FRAMEIT", "declarations": [ - { + { "name": "PointA", "type": "Point", "identifier": "URI" @@ -56,8 +53,7 @@ "name": "PointB", "type": "Point", "identifier": "URI" - } - , + }, { "name": "PointC", "type": "Point", @@ -67,20 +63,18 @@ "name": "Distance AC", "type": "Distance", "identifier": "URI" - } - , + }, { "name": "Angle CAB", "type": "Angle", "identifier": "URI" - } - , + }, { "name": "Angle ACB", "type": "Angle", "identifier": "URI" } - ] } - ] \ No newline at end of file + ] +} \ No newline at end of file