Topic: Acitivate/ disactivate Buildings
Hi,
How can I activate desactivate buildings in Runtime With a switch button ?
You are not logged in. Please login or register.
Infinity Code Forum → Online Maps Help → Acitivate/ disactivate Buildings
Hi,
How can I activate desactivate buildings in Runtime With a switch button ?
Hello.
Unfortunately, the current version of Online Maps does not have a good way to deactivate buildings.
Currently you can use this way:
using System.Reflection;
using UnityEngine;
public class DeactivateBuildings:MonoBehaviour
{
private bool activated = true;
private void OnGUI()
{
if (GUILayout.Button(activated ? "Deactivate" : "Activate"))
{
activated = !activated;
if (activated)
{
OnlineMapsBuildings.instance.enabled = true;
FieldInfo fTopLeft = typeof(OnlineMapsBuildings).GetField("topLeft", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo fBottomRight = typeof(OnlineMapsBuildings).GetField("bottomRight", BindingFlags.Instance | BindingFlags.NonPublic);
fTopLeft.SetValue(OnlineMapsBuildings.instance, new OnlineMapsVector2i());
fBottomRight.SetValue(OnlineMapsBuildings.instance, new OnlineMapsVector2i());
}
else
{
MethodInfo method = typeof(OnlineMapsBuildings).GetMethod("RemoveAllBuildings", BindingFlags.Instance | BindingFlags.NonPublic);
method.Invoke(OnlineMapsBuildings.instance, null);
OnlineMapsBuildings.instance.enabled = false;
}
}
}
}
Yes, it's a dirty hack.
We will add the ability to correctly activate and deactivate buildings in the next version.
Hi,
I try to implement this function to activate/deactivate the buildings, But it's not working very well and it take much time to be executed.
I saw that you have released a new version of the plugin with the ability of activating/deactivating the buildings, but I am stick with the version 2.5.12.1 and can not update to the next version.
Is there a possibility or exemple for this version to activate/deactivate buildings with a clean process?
Thanks in advance
Hello.
The example for version 2.5.12 or older is above.
Please explain in detail what exactly does not work well, and how you expected it to work.
Infinity Code Forum → Online Maps Help → Acitivate/ disactivate Buildings
Powered by PunBB, supported by Informer Technologies, Inc.