ObjectSelector

Updated on August 3, 2022

public void DeselectObject()

Deselects the currently selected object. This includes reapplying the objects original material as well as closing any menu if there is one.

public void SelectObject(GameObject selectedObj)

Selects the given object. This applies the selected material applied in the inspector as well as opens any menu set via the GridObjectOptions if there is one whilst also setting the class variable selectedObj of GridObjectOptions. This then allows certain other functions of that object to work such as Move.

The selected object should have the GridObject class on it as this class stores its own original material to reapply after deselecting.

public ObjectSelector objectSelector;
public Button btn;
public GameObject objectToSelect;

void Start() 
{
    btn.onClick.AddListener(() => 
    {
         objectSelector.SelectObject(objectToSelect);
    });
}

public void HideCanvas()

If you have a canvas in the SelectorCanvas inspector slot, hide it.

public void ShowCanvas()

If you have a canvas in the SelectorCanvas inspector slot, show it.

public void ResetCanvas()

Usually called after deleting an object or when not hovering over an object. This moves the canvas size back to the grid cell size.

public void AdjustCanvasImage()

Moves the canvas image to the center of the hovered object as well as initiating the change of the sizeDelta.

public Vector2 GetObjectWidthHeight(List checkPosList)

Given a checkPosList, calculates how many cells the object takes up both width and height. For example if the object has center and center left enabled, it would result in finding Vector2(1, 2).

This and the above method are often called together with this method being called first.

Still need help? Contact support at support@golemitegames.com

Please describe your issue in detail and if possible, provide screenshots to help us understand your problem better and answer your question more effectively.