private bool IncludeInMerge(GameObject go) { // If prefab is not supposed to be included in the merge, don't include its material name MAST_Prefab_Component prefabComponent = go.GetComponent <MAST_Prefab_Component>(); if (prefabComponent != null) { return(prefabComponent.includeInMerge); } // If no MAST prefab component was attached, include it in the merge return(true); }
// Check if a GameObject already exists here and if neither can be placed inside others private static bool GameObjectAlreadyHere() { // Get array containing all Colliders within 1.5f square box at placement position Collider[] colliders = Physics.OverlapBox( MAST_Placement_Visualizer.GetGameObject().transform.position, new Vector3(0.75f, 0.75f, 0.75f)); // Loop through each GameObject inside or colliding with this OverlapBox foreach (Collider collider in colliders) { // If the nearby GameObject has a parent if (collider.gameObject.transform.parent != null) { // Get Parent GameObject for the GameObject containing this Collider GameObject nearObject = collider.gameObject.transform.parent.gameObject; // If near GameObject is not the visualizer itself if (nearObject.name != "MAST_Visualizer") { // If the placed GameObject shares the same Position as the near GameObject if (nearObject.transform.position == MAST_Placement_Visualizer.GetGameObject().transform.position) { //TODO: Add rotation check as well // Get the MAST Component script of the near GameObject MAST_Prefab_Component nearComponent = nearObject.GetComponent <MAST_Prefab_Component>(); // If neither the GameObject nor placed GameObject can be placed inside others if (!MAST_Placement_Helper.GetPlaceInsideOthers() && !nearComponent.placeInsideOthers) { // Return true "Not safe to place" return(true); } } } } } // Return false "Safe to place" return(false); }