Set Hide and Display Buttons in Game Menu
Closed this issue · 4 comments
Hello!
Thank you for sharing this code ! It has been very helpful to me :)
I managed to use your code to render my point clouds in Unity, and i am now trying to use Hide and Display buttons in game (not in the Editor). I thought I would find code for Hide and Display fonctions in the DynamicPointCloudSet script but I didn't ...
I tried to use "SetActive buttons" but I only can Hide the point cloud, but not display it back, I have to restart the game for that ...
Do you have an idea where i can find the code corresponding to those Hide and Display buttons ?
Thanks in advance.
Hi!
Yes, the code for the buttons is in PointCloudRenderer\Assets\Scripts\Editor\DynamicPointCloudSetEditor.cs. As you will see, it is very simple and just calls pointcloudset.PointRenderer.Hide() and pointcloudset.PointRenderer.Display().
Is that helpful for you?
Simon
Hi!
Thanks for your answer !
I managed to hide the clouds that have already been loaded with this code :
public void Hide_SurSolPointCloud()
{
for (int i = 0; i < SurSolPointCloud.transform.childCount; i++)
{
GameObject child = SurSolPointCloud.transform.GetChild(i).gameObject;
child.gameObject.SetActive(false);
Show_button_SurSolPointCloud.gameObject.SetActive(true);
Hide_button_SurSolPointCloud.gameObject.SetActive(false);
}
}
But it doesn't work well : when I move a bit or look in a new direction, it display the new loaded Points ...
So it only hides the points that are visible when i click on the Hide button.
I will look at the DynamicPointCloudSetEditor script and try to use the PointRender Hide and Display methods in my script and tell you if it works :)
Thank you again,
Théo
Hello again !
So i'm trying with this code :
public void Hide_SurSolPointCloud()
{
SurSolPointCloud.PointRenderer.Hide();
}
but i get a CS1061 error : Assets\MenuScript.cs(66,23): error CS1061: 'GameObject' does not contain a definition for 'PointRenderer' and no accessible extension method 'PointRenderer' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)
Do you know where is my mistake ?
here is my complete code : MenuScript.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using BAPointCloudRenderer.CloudController;
public class MenuScript : MonoBehaviour
{
public GameObject SolPointCloud;
public GameObject SurSolPointCloud;
public GameObject Hide_button_SolPointCloud;
public GameObject Show_button_SolPointCloud;
public GameObject Hide_button_SurSolPointCloud;
public GameObject Show_button_SurSolPointCloud;
void Start()
{
Show_button_SolPointCloud.gameObject.SetActive(false);
Hide_button_SolPointCloud.gameObject.SetActive(true);
SolPointCloud.gameObject.SetActive(true);
Show_button_SurSolPointCloud.gameObject.SetActive(false);
Hide_button_SurSolPointCloud.gameObject.SetActive(true);
SurSolPointCloud.gameObject.SetActive(true);
}
public void Hide_SolPointCloud()
{
SolPointCloud.PointRenderer.Hide();
Show_button_SolPointCloud.gameObject.SetActive(true);
Hide_button_SolPointCloud.gameObject.SetActive(false);
}
public void Hide_SurSolPointCloud()
{
SurSolPointCloud.PointRenderer.Hide();
Show_button_SurSolPointCloud.gameObject.SetActive(true);
Hide_button_SurSolPointCloud.gameObject.SetActive(false);
}
public void Show_SolPointCloud()
{
SolPointCloud.PointRenderer.Display();
Show_button_SolPointCloud.gameObject.SetActive(false);
Hide_button_SolPointCloud.gameObject.SetActive(true);
}
public void Show_SurSolPointCloud()
{
SurSolPointCloud.PointRenderer.Display();
Show_button_SurSolPointCloud.gameObject.SetActive(false);
Hide_button_SurSolPointCloud.gameObject.SetActive(true);
}
}
I think I have to refer to the DynamicPointCloudSetEditor script but I don't know how ...
If you have an idea, I would be gratefull !
Théo
Ok nevermind !
I simply had to declare my pointcloudset as a pointcloudset and not as a simple gameobject ...
New working code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using BAPointCloudRenderer.CloudController;
using BAPointCloudRenderer.CloudData;
using BAPointCloudRenderer.Loading;
using BAPointCloudRenderer.ObjectCreation;
public class MenuScript : MonoBehaviour
{
public DynamicPointCloudSet SolPointCloud;
public DynamicPointCloudSet SurSolPointCloud;
public GameObject Hide_button_SolPointCloud;
public GameObject Show_button_SolPointCloud;
public GameObject Hide_button_SurSolPointCloud;
public GameObject Show_button_SurSolPointCloud;
void Start()
{
Show_button_SolPointCloud.gameObject.SetActive(false);
Hide_button_SolPointCloud.gameObject.SetActive(true);
SolPointCloud.gameObject.SetActive(true);
Show_button_SurSolPointCloud.gameObject.SetActive(false);
Hide_button_SurSolPointCloud.gameObject.SetActive(true);
SurSolPointCloud.gameObject.SetActive(true);
}
public void Hide_SolPointCloud()
{
SolPointCloud.PointRenderer.Hide();
Show_button_SolPointCloud.gameObject.SetActive(true);
Hide_button_SolPointCloud.gameObject.SetActive(false);
}
public void Hide_SurSolPointCloud()
{
SurSolPointCloud.PointRenderer.Hide();
Show_button_SurSolPointCloud.gameObject.SetActive(true);
Hide_button_SurSolPointCloud.gameObject.SetActive(false);
}
public void Show_SolPointCloud()
{
SolPointCloud.PointRenderer.Display();
Show_button_SolPointCloud.gameObject.SetActive(false);
Hide_button_SolPointCloud.gameObject.SetActive(true);
}
public void Show_SurSolPointCloud()
{
SurSolPointCloud.PointRenderer.Display();
Show_button_SurSolPointCloud.gameObject.SetActive(false);
Hide_button_SurSolPointCloud.gameObject.SetActive(true);
}
}
Thank you for your help and your patience with beginners !