Exemplo n.º 1
0
        /// <summary>
        /// Removes Form from Application.OpenForms collection.
        /// </summary>
        /// <param name="form">The form to be removed.</param>
        private static void RemoveOpenForms(this Form form)
        {
            ReadOnlyCollectionBase col  = Application.OpenForms;
            PropertyInfo           list = col.GetType().GetProperty("InnerList", BindingFlags.CreateInstance | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (list != null)
            {
                ArrayList array = (ArrayList)list.GetValue(col, null);
                array.Remove(form);
            }
        }
Exemplo n.º 2
0
    public static GameObject GetObjectInSpaceOnTouchByTag(Vector3 position, string objectTag)
    {
        ReadOnlyCollectionBase ray = Camera.main.ScreenPointToRay(position);

        RaycastHit[] raycastHits;
        raycastHits = Physics.RaycastAll(ray);
        foreach (RaycastHit hit in raycastHits)
        {
            if (hit.collider.tag == objectTag)
            {
                return(hit.collider.gameObject);
            }
        }
        return(null);
    }