protected void ActivateSelecetedRaycastCheckersNEW(GameObject[] selectedGameObjects) { List <CS_RaycastChecker> raycastCheckersToRemoveFromInactiveList = new List <CS_RaycastChecker>(); // cycle selected objects and get their raycast checkers foreach (GameObject goRaycastChecker in selectedGameObjects) { CS_RaycastChecker selectedRC = goRaycastChecker.GetComponent <CS_RaycastChecker>(); // if the selected object is a raycast checker, activate it if (selectedRC) { // serialize the raycast checker SerializedObject serializedRC = new SerializedObject(selectedRC); // get the raycaster active property SerializedProperty raycasterActiveProperty = serializedRC.FindProperty("raycasterActive"); bool prevRCActiveValue = raycasterActiveProperty.boolValue; raycasterActiveProperty.boolValue = true; // activate the raycast checker // apply the serialized object property changes serializedRC.ApplyModifiedProperties(); // if the editor is running if (EditorApplicationRunning) { // if value has changed if (prevRCActiveValue != raycasterActiveProperty.boolValue) { // clear the view mesh selectedRC.ClearViewMesh(); } } raycastCheckersToRemoveFromInactiveList.Add(selectedRC); } } // if raycast checkers are to be moved lists if (raycastCheckersToRemoveFromInactiveList.Count > 0) { foreach (CS_RaycastChecker activeRaycastChecker in raycastCheckersToRemoveFromInactiveList) { // if the raycast checker is in the inactive raycast checkers list if (inactiveRaycastCheckers.Contains(activeRaycastChecker)) { inactiveRaycastCheckers.Remove(activeRaycastChecker); } } raycastCheckersToRemoveFromInactiveList.Clear(); } }
protected void DeactivateSelectedRaycastCheckersNEW(GameObject[] selectedGameObjects) { // cycle selected objects and get their raycast checkers foreach (GameObject goRaycastChecker in selectedGameObjects) { CS_RaycastChecker selectedRC = goRaycastChecker.GetComponent <CS_RaycastChecker>(); // if the selected object is a raycast checker, activate it if (selectedRC) { // serialize the raycast checker SerializedObject serializedRC = new SerializedObject(selectedRC); // get the raycaster active property SerializedProperty raycasterActiveProperty = serializedRC.FindProperty("raycasterActive"); bool prevRCActiveValue = raycasterActiveProperty.boolValue; raycasterActiveProperty.boolValue = false; // if the selected raycast checker is not in the inactive raycast checker list, add it if (!inactiveRaycastCheckers.Contains(selectedRC)) { inactiveRaycastCheckers.Add(selectedRC); } // apply the serialized object property changes serializedRC.ApplyModifiedProperties(); // if the editor is running if (EditorApplicationRunning) { // if value has changed if (prevRCActiveValue != raycasterActiveProperty.boolValue) { // clear the view mesh selectedRC.ClearViewMesh(); } } } } }