Skip to content
Snippets Groups Projects
Commit d068c7d2 authored by BenniHome's avatar BenniHome
Browse files

scroll generation from json nearly finished

parent 93c04775
No related branches found
No related tags found
No related merge requests found
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
using System.IO; using System.IO;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using TMPro;
public class DisplayScrolls : MonoBehaviour 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) ...@@ -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); 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 // Start is called before the first frame update
void Start() void Start()
{ {
//get Scrolls from Backend;
//TODO REST-Call instead of Json-File
string path = "Mock-Scrolls.json"; string path = "Mock-Scrolls.json";
string jsonString = File.ReadAllText(path); string jsonString = File.ReadAllText(path);
jsonString = jsonString.Replace(System.Environment.NewLine, ""); jsonString = jsonString.Replace(System.Environment.NewLine, "");
jsonString = jsonString.Replace("\t", ""); jsonString = jsonString.Replace("\t", "");
Debug.Log(jsonString);
Scroll[] scrollsRead = JsonUtility.FromJson<Scroll[]>(jsonString); ScrollArrayWrapper scrollsRead = new ScrollArrayWrapper();
//this.scrolls = scrollsRead; 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;
}
} }
} }
...@@ -11,6 +11,8 @@ GameObject: ...@@ -11,6 +11,8 @@ GameObject:
- component: {fileID: 659044494318708747} - component: {fileID: 659044494318708747}
- component: {fileID: 3213819025273557502} - component: {fileID: 3213819025273557502}
- component: {fileID: 2305338954152611092} - component: {fileID: 2305338954152611092}
- component: {fileID: 114452647229146242}
- component: {fileID: 114809707957640338}
m_Layer: 5 m_Layer: 5
m_Name: ScrollDisplay m_Name: ScrollDisplay
m_TagString: Untagged m_TagString: Untagged
...@@ -29,7 +31,7 @@ RectTransform: ...@@ -29,7 +31,7 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 3182838857086358575} - {fileID: 5295466371659185427}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -73,7 +75,54 @@ MonoBehaviour: ...@@ -73,7 +75,54 @@ MonoBehaviour:
m_FillClockwise: 1 m_FillClockwise: 1
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 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: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -81,23 +130,23 @@ GameObject: ...@@ -81,23 +130,23 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 3182838857086358575} - component: {fileID: 5295466371659185427}
- component: {fileID: 5561432925616113774} - component: {fileID: 6923828144562967227}
- component: {fileID: 4926976350478616173} - component: {fileID: 5867570113647991285}
m_Layer: 5 m_Layer: 5
m_Name: Text m_Name: Text (TMP)
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!224 &3182838857086358575 --- !u!224 &5295466371659185427
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {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_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
...@@ -110,43 +159,121 @@ RectTransform: ...@@ -110,43 +159,121 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5561432925616113774 --- !u!222 &6923828144562967227
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7738162277464361060} m_GameObject: {fileID: 5809183911047187526}
m_CullTransparentMesh: 0 m_CullTransparentMesh: 0
--- !u!114 &4926976350478616173 --- !u!114 &5867570113647991285
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7738162277464361060} m_GameObject: {fileID: 5809183911047187526}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} 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_RaycastTarget: 1
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_FontData: m_text: New Text
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} m_isRightToLeft: 0
m_FontSize: 14 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_FontStyle: 0 m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_BestFit: 0 m_fontSharedMaterials: []
m_MinSize: 10 m_fontMaterial: {fileID: 0}
m_MaxSize: 40 m_fontMaterials: []
m_Alignment: 0 m_fontColor32:
m_AlignByGeometry: 0 serializedVersion: 2
m_RichText: 1 rgba: 4278190080
m_HorizontalOverflow: 0 m_fontColor: {r: 0, g: 0, b: 0, a: 1}
m_VerticalOverflow: 0 m_enableVertexGradient: 0
m_LineSpacing: 1 m_colorMode: 3
m_Text: New Text 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}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScrollClickedScript: MonoBehaviour
{
public Scroll scroll;
public void onClick() {
Debug.Log("clicked");
}
}
fileFormatVersion: 2
guid: 11ddd9731d735dd47b5581d7f335747e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -205,7 +205,6 @@ RectTransform: ...@@ -205,7 +205,6 @@ RectTransform:
- {fileID: 1181841652} - {fileID: 1181841652}
- {fileID: 1243429077} - {fileID: 1243429077}
- {fileID: 274389189} - {fileID: 274389189}
- {fileID: 6421936590152144000}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -265,8 +264,10 @@ MonoBehaviour: ...@@ -265,8 +264,10 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
scrolls: [] scrolls: []
x_Start: -175 ScrollPrefab: {fileID: 3173330253721512196, guid: a6a9a3ebdb022e546a21d9f9ff148261,
y_Start: 0 type: 3}
x_Start: -240
y_Start: 200
X_Pacece_Between_Items: 110 X_Pacece_Between_Items: 110
y_Pacece_Between_Items: 110 y_Pacece_Between_Items: 110
number_of_Column: 3 number_of_Column: 3
...@@ -400,7 +401,8 @@ RectTransform: ...@@ -400,7 +401,8 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children:
- {fileID: 6421936590152144000}
m_Father: {fileID: 249048815} m_Father: {fileID: 249048815}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
...@@ -795,7 +797,7 @@ PrefabInstance: ...@@ -795,7 +797,7 @@ PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 249048815} m_TransformParent: {fileID: 1181841652}
m_Modifications: m_Modifications:
- target: {fileID: 1410316395273548761, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548761, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
...@@ -820,17 +822,17 @@ PrefabInstance: ...@@ -820,17 +822,17 @@ PrefabInstance:
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
...@@ -840,7 +842,7 @@ PrefabInstance: ...@@ -840,7 +842,7 @@ PrefabInstance:
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 3 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
...@@ -860,12 +862,12 @@ PrefabInstance: ...@@ -860,12 +862,12 @@ PrefabInstance:
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: -660.0001 value: -0.00012207031
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: -253.04349 value: 0.000045776367
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 1410316395273548762, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
...@@ -925,7 +927,7 @@ PrefabInstance: ...@@ -925,7 +927,7 @@ PrefabInstance:
- target: {fileID: 2966758062926209900, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 2966758062926209900, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 0.000032980104 value: 0.00000961381
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4536977264099877230, guid: efd7037a57100574780bb26bea0c0683, - target: {fileID: 4536977264099877230, guid: efd7037a57100574780bb26bea0c0683,
type: 3} type: 3}
......
[ {
"scrolls": [
{ {
"problemTheory": "bla", "problemTheory": "bla",
"solutioTheory": "blubb", "solutionTheory": "blubb",
"label": "Pythagoras", "label": "Pythagoras",
"description": "a quadrat plus b quadrat ist c quadrat", "description": "a quadrat plus b quadrat ist c quadrat",
"declarations": [ "declarations": [
...@@ -14,26 +15,22 @@ ...@@ -14,26 +15,22 @@
"name": "PointB", "name": "PointB",
"type": "Point", "type": "Point",
"identifier": "URI" "identifier": "URI"
} },
,
{ {
"name": "PointC", "name": "PointC",
"type": "Point", "type": "Point",
"identifier": "URI" "identifier": "URI"
} },
,
{ {
"name": "Distance AC", "name": "Distance AC",
"type": "Distance", "type": "Distance",
"identifier": "URI" "identifier": "URI"
} },
,
{ {
"name": "Distance BC", "name": "Distance BC",
"type": "Point", "type": "Point",
"identifier": "URI" "identifier": "URI"
} },
,
{ {
"name": "Angle ACB", "name": "Angle ACB",
"type": "Angle", "type": "Angle",
...@@ -43,11 +40,11 @@ ...@@ -43,11 +40,11 @@
}, },
{ {
"problemTheory": "bla", "problemTheory": "bla",
"solutioTheory": "blubb", "solutionTheory": "blubb",
"label": "Tangens", "label": "Tangens",
"description": "Das standart Beispiel für FRAMEIT", "description": "Das standart Beispiel für FRAMEIT",
"declarations": [ "declarations": [
{ {
"name": "PointA", "name": "PointA",
"type": "Point", "type": "Point",
"identifier": "URI" "identifier": "URI"
...@@ -56,8 +53,7 @@ ...@@ -56,8 +53,7 @@
"name": "PointB", "name": "PointB",
"type": "Point", "type": "Point",
"identifier": "URI" "identifier": "URI"
} },
,
{ {
"name": "PointC", "name": "PointC",
"type": "Point", "type": "Point",
...@@ -67,20 +63,18 @@ ...@@ -67,20 +63,18 @@
"name": "Distance AC", "name": "Distance AC",
"type": "Distance", "type": "Distance",
"identifier": "URI" "identifier": "URI"
} },
,
{ {
"name": "Angle CAB", "name": "Angle CAB",
"type": "Angle", "type": "Angle",
"identifier": "URI" "identifier": "URI"
} },
,
{ {
"name": "Angle ACB", "name": "Angle ACB",
"type": "Angle", "type": "Angle",
"identifier": "URI" "identifier": "URI"
} }
] ]
} }
] ]
\ No newline at end of file }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment