Hello,
I have created an info window script to show informations panel above selected element in VR scene using HTC Vive.
I have made a GameObject in the hierarchy and associated a C# script.
In the script I created a canvas named “InfoWindow” and added a panel. I setted a black background using an image to the panel so I can see it on screen.
The problem is when I try to add other element to the panel. Nothing appear on it.
Here is my code.
void Start () {
this.infoWindow = new GameObject(“IDCInfoWindow”);
this.infoWindow.AddComponent().sizeDelta = new Vector2(900, 900);
this.infoWindow.GetComponent().localScale = new Vector3(0.005f, 0.005f, 0);
Canvas c = this.infoWindow.AddComponent();
c.renderMode = RenderMode.WorldSpace;
this.infoWindow.AddComponent();
this.infoWindow.AddComponent();
this.panel = new GameObject(“Panel”);
this.panel.AddComponent();
this.panel.transform.SetParent(this.infoWindow.transform, false);
// Ajout background
Image i = this.panel.AddComponent();
i.rectTransform.sizeDelta = new Vector2(900, 900);
i.color = Color.black;
// Ajout text titre
GameObject titleTextGO = new GameObject(“titleTextGO”);
titleTextGO.transform.SetParent(this.panel.transform);
titleTextGO.AddComponent();
this.titleText = titleTextGO.AddComponent();
this.titleText.text = “Liste des documents technique liés à la vanne VLV1”;
this.titleText.fontSize = 50;
this.titleText.color = Color.white;
//this.titleText.rectTransform.position = new Vector3(0, 0, 0);
this.titleText.rectTransform.sizeDelta = new Vector2(400, 400);
this.titleText.GetComponent().anchoredPosition = new Vector3(0, 0, 0);
this.titleText.GetComponent().localScale = new Vector3(1, 1, 0);
// Ajout Bouton Atex
this.btAtex = new GameObject(“BoutonAtex”);
btAtex.transform.SetParent(this.panel.transform);
Button bt1 = this.btAtex.AddComponent();
ColorBlock cb = bt1.colors;
cb.normalColor = Color.white;
bt1.colors = cb;
//this.infoWindow.SetActive(false);
}
I’ve done all the creation inside the start method.
I hope you have an idea.
Thank you,
Y.