public void CreateVertex() { var texture = _defaultTexture; if (!string.IsNullOrEmpty(_imagePath.text)) { texture = Texture2D.whiteTexture; using var fs = new FileStream(_imagePath.text, FileMode.Open); var bytes = new byte[fs.Length]; fs.Read(bytes, 0, bytes.Length); texture.LoadImage(bytes); } var customFont = FontsGenerator.GetOrCreateFont("Broadway", 32); var selectFrame = Texture2DExtension.ResizeTexture(Resources.Load <Texture2D>(_selectFrameTexture), 200, 200); selectFrame.name = "SelectFrame"; var TextTextureFactory = new TextTextureFactory(customFont, 0); var imageParameters = new BillboardParameters(texture, scale: _scale.Vector * 3f); var selectFrameParameters = new BillboardParameters(selectFrame, scale: _scale.Vector * 6f, isMonoColor: true, useCache: false); var text = TextTextureFactory.MakeTextTexture(_name.text, true); float scale = 10; var textParameters = new BillboardParameters(text, new Vector4(0, -Mathf.Max(_scale.Vector.x, _scale.Vector.y) - 10, 0, 0), new Vector2(scale, text.height * 1.0f / text.width * scale)); var currentVertex = AbstractGraph.GetComponent <AbstractGraph>().SpawnVertex <SelectableVertex, SelectableVertexParameters>( new SelectableVertexParameters(new[] { imageParameters, textParameters }, selectFrameParameters, _positon.Vector)); }
public GraphForBillboardVertexes CreateGraph() { var graph = new GameObject("Graph"); var graphControler = graph.AddComponent <GraphForBillboardVertexes>(); Graphs.Add(graphControler); graphControler.SetupParams(new GraphParameters(new Vector3(0, -20), "Test")); var customFont = FontsGenerator.GetOrCreateFont("Broadway", 32); var mainTexture = Texture2DExtension.ResizeTexture(Resources.Load <Texture2D>(_mainTexture), 200, 200); mainTexture.name = "Target"; var selectFrame = Texture2DExtension.ResizeTexture(Resources.Load <Texture2D>(_selectFrameTexture), 200, 200); selectFrame.name = "SelectFrame"; var textTextureFactory = new TextTextureFactory(customFont, 0); var baseScale = Vector2.one; var imageParameters = new BillboardParameters(mainTexture, scale: baseScale * 3f, useCache: true); var selectFrameParameters = new BillboardParameters(selectFrame, scale: baseScale * 6f, isMonoColor: true, useCache: false); var edgeParameters = new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.white, true), new SpringParameters(1, 10)); BillboardVertex?vertex = null; for (var i = 0; i < 1000; ++i) { var text = textTextureFactory.MakeTextTexture($"Vertex{i}", true); const float scale = 10; var textParameters = new BillboardParameters(text, new Vector4(0, -5, 0, 0), new Vector2(scale, text.height * 1.0f / text.width * scale)); var currentVertex = graphControler.SpawnVertex <SelectableVertex, SelectableVertexParameters>( new SelectableVertexParameters(new[] { imageParameters, textParameters }, selectFrameParameters, new Vector3(i % 32 * 10, i / 32 * 10))); if (vertex != null) { currentVertex.Link <StretchableEdge, StretchableEdgeParameters>(vertex, edgeParameters); } vertex = currentVertex; } return(graphControler); }
public override void InitTask() { var graph = new GameObject("Graph"); var graphControler = graph.AddComponent <GraphForBillboardVertexes>(); Graphs.Add(graphControler); graphControler.SetupParams(new GraphParameters(new Vector3(0, -20), "Test")); var customFont = FontsGenerator.GetOrCreateFont("Arial", 32); var mainTexture = Texture2DExtension.ResizeTexture(Resources.Load <Texture2D>(_mainTexture), 800, 800); mainTexture.name = "Target"; var dotTexture = Texture2DExtension.ResizeTexture(Resources.Load <Texture2D>(_mainTexture), 800, 800); mainTexture.name = "Dot"; var selectFrame = Texture2DExtension.ResizeTexture(Resources.Load <Texture2D>(_selectFrameTexture), 800, 800); selectFrame.name = "SelectFrame"; var textTextureFactory = new TextTextureFactory(customFont, 0); var baseScale = Vector2.one; var imageParameters = new BillboardParameters(mainTexture, scale: baseScale * 3f, useCache: true); var selectFrameParameters = new BillboardParameters(selectFrame, scale: baseScale * 6f, isMonoColor: true, useCache: false); var text = textTextureFactory.MakeTextTexture($"Select Me", true); const float scale = 10; var textParameters = new BillboardParameters(text, new Vector4(0, -5, 0, 0), new Vector2(scale, text.height * 1.0f / text.width * scale), isMonoColor: true, monoColor: Color.white); _selectableVertex = graphControler.SpawnVertex <SelectableVertex, SelectableVertexParameters>( new SelectableVertexParameters(new[] { imageParameters, textParameters }, selectFrameParameters, new Vector3(-20, 20))); var dotImageParameters = new BillboardParameters(mainTexture, scale: baseScale * 3f, useCache: true); text = textTextureFactory.MakeTextTexture($"Dot 1", true); textParameters = new BillboardParameters(text, new Vector4(0, -5, 0, 0), new Vector2(scale, text.height * 1.0f / text.width * scale), isMonoColor: true, monoColor: Color.white); _dot1 = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>( new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(0, 20))); text = textTextureFactory.MakeTextTexture($"Dot 2", true); textParameters = new BillboardParameters(text, new Vector4(0, -5, 0, 0), new Vector2(scale, text.height * 1.0f / text.width * scale), isMonoColor: true, monoColor: Color.white); _dot2 = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>( new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(20, 20))); text = textTextureFactory.MakeTextTexture($"Move me", true); textParameters = new BillboardParameters(text, new Vector4(0, -5, 0, 0), new Vector2(scale, text.height * 1.0f / text.width * scale), isMonoColor: true, monoColor: Color.white); _moveVertex = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>( new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(30, 20, -10))); text = textTextureFactory.MakeTextTexture($"Click me", true); textParameters = new BillboardParameters(text, new Vector4(0, -5, 0, 0), new Vector2(scale, text.height * 1.0f / text.width * scale), isMonoColor: true, monoColor: Color.white); var clickVeretex = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>( new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(-50, 20, -10))); var snowPref = Resources.Load <GameObject>(@"Prefabs\Snowflake"); clickVeretex.gameObject.AddComponent <Button3D>().Action = (g) => { _clickCount++; Destroy(Instantiate(snowPref, clickVeretex.transform.position, Quaternion.identity), 2); }; var colors = new List <Color>(7) { new Color(1f, 0f, 0f), new Color(1f, 127f / 255f, 0f), new Color(1f, 1f, 0f), new Color(0f, 1f, 0f), new Color(0f, 0f, 1f), new Color(75f / 255f, 0f, 130f / 255f), new Color(143f, 0f, 1f), }; var edgeTypes = new List <(Type type, EdgeParameters parameters)>(1) { (typeof(StretchableEdge), new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.white), new SpringParameters(1, 10))) }; var player = CreatePlayer(); player.SetupParams(new PlayerParameters(Vector3.zero, Vector3.zero, SceneParametersContainer.PlayerSpeed, 20, isVR: SceneParametersContainer.IsVR, new ToolConfig[4] { new ToolConfig(typeof(SelectItemTool), new SelectItemToolParams(colors)), new ToolConfig(typeof(GrabItemTool), new GrabItemToolParams()), new ToolConfig(typeof(EdgeCreaterTool), new EdgeCreaterToolParams(edgeTypes)), new ToolConfig(typeof(ClickTool), new ClickToolParams()) })); }
public override void InitTask() { var player = CreatePlayer(); var toolConfig = new ToolConfig(typeof(ClickTool), new ClickToolParams()); player.SetupParams(new PlayerParameters(new Vector3(0, 0, -50), Vector3.zero, SceneParametersContainer.PlayerSpeed, sceneInfo: "Hub scene", isVR: SceneParametersContainer.IsVR, toolConfigs: new[] { toolConfig })); //ToDo : Replace with auto generation var customFont = FontsGenerator.GetOrCreateFont("Arial", 128); var textTextureFactory = new TextTextureFactory(customFont, 0); { var graph = new GameObject("Tutorial tasks"); var graphControler = graph.AddComponent <GraphForBillboardVertexes>(); graphControler.ColliderEnable = false; Graphs.Add(graphControler); var baseScale = Vector2.one; graphControler.SetupParams(new GraphParameters(new Vector3(-20, 0, 0), "Tutorial tasks")); var text = textTextureFactory.MakeTextTexture("Tools test", true); var mainTexture = Texture2DExtension.ResizeTexture(Resources.Load <Texture2D>(_mainTexture), 400, 400); var imageParameters = new BillboardParameters(mainTexture, Vector4.zero, new Vector2(9, 2), useCache: true); var textParameters = new BillboardParameters(text, Vector4.zero, new Vector2(4, 0.4f), useCache: false, isMonoColor: true, monoColor: Color.white); var vertexParameters = new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(-30, 18, 0)); var toolsTest = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>(vertexParameters); toolsTest.gameObject.AddComponent <Button3D>().Action = (gameObject) => SceneLoader.Instance.LoadScene <ToolTestTasks>(); text = textTextureFactory.MakeTextTexture("Movement test", true); textParameters = new BillboardParameters(text, Vector4.zero, new Vector2(4, 0.4f), isMonoColor: true, monoColor: Color.white, useCache: false); vertexParameters = new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(-20, 9, 0)); var movementTest = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>(vertexParameters); movementTest.gameObject.AddComponent <Button3D>().Action = (gameObject) => SceneLoader.Instance.LoadScene <MovementTestTask>(); movementTest.Link <StretchableEdge, StretchableEdgeParameters>(toolsTest, new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.green), new SpringParameters(1, 5))); } { var graph = new GameObject("Beautiful scenes"); var graphControler = graph.AddComponent <GraphForBillboardVertexes>(); graphControler.ColliderEnable = false; Graphs.Add(graphControler); var baseScale = Vector2.one; graphControler.SetupParams(new GraphParameters(new Vector3(20, 0, 0), "Beautiful scenes")); var text = textTextureFactory.MakeTextTexture("Plants Kingdom", true); var mainTexture = Texture2DExtension.ResizeTexture(Resources.Load <Texture2D>(_mainTexture), 400, 400); var imageParameters = new BillboardParameters(mainTexture, Vector4.zero, new Vector2(9, 2), useCache: true); var textParameters = new BillboardParameters(text, Vector4.zero, new Vector2(4, 0.4f), useCache: false, isMonoColor: true, monoColor: Color.white); var vertexParameters = new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(10, 10, 0)); var v1 = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>(vertexParameters); v1.gameObject.AddComponent <Button3D>().Action = (gameObject) => SceneLoader.Instance.LoadScene <PlantsKingdom>(); text = textTextureFactory.MakeTextTexture("Social graph 1", true); textParameters = new BillboardParameters(text, Vector4.zero, new Vector2(4, 0.4f), isMonoColor: true, monoColor: Color.white, useCache: false); vertexParameters = new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(30, 19, 0)); var v2 = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>(vertexParameters); v2.gameObject.AddComponent <Button3D>().Action = (gameObject) => SceneLoader.Instance.LoadScene <OneGroupEnemyAndFriendsScene>(); text = textTextureFactory.MakeTextTexture("Social graph 2", true); textParameters = new BillboardParameters(text, Vector4.zero, new Vector2(4, 0.4f), isMonoColor: true, monoColor: Color.white, useCache: false); vertexParameters = new BillboardVertexParameters(new[] { imageParameters, textParameters }, new Vector3(20, 28, 0)); var v3 = graphControler.SpawnVertex <BillboardVertex, BillboardVertexParameters>(vertexParameters); v3.gameObject.AddComponent <Button3D>().Action = (gameObject) => SceneLoader.Instance.LoadScene <MultyGroupFriendsScene>(); v1.Link <StretchableEdge, StretchableEdgeParameters>(v2, new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.green), new SpringParameters(1, 5))); v2.Link <StretchableEdge, StretchableEdgeParameters>(v1, new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.green), new SpringParameters(1, 5))); v1.Link <StretchableEdge, StretchableEdgeParameters>(v3, new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.green), new SpringParameters(1, 5))); v3.Link <StretchableEdge, StretchableEdgeParameters>(v1, new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.green), new SpringParameters(1, 5))); v2.Link <StretchableEdge, StretchableEdgeParameters>(v3, new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.green), new SpringParameters(1, 5))); v3.Link <StretchableEdge, StretchableEdgeParameters>(v2, new StretchableEdgeParameters(new StretchableEdgeMaterialParameters(Color.green), new SpringParameters(1, 5))); } }