public static CSGModel EndPicking(HideFlagsState state, UnityEngine.GameObject pickedObject) { if (state == null || state.hideFlags == null) { return(null); } foreach (var pair in state.hideFlags) { pair.Key.hideFlags = pair.Value; } if (object.Equals(pickedObject, null)) { return(null); } if (state.generatedComponents == null) { return(null); } CSGModel model; if (state.generatedComponents.TryGetValue(pickedObject, out model)) { return(model); } return(null); }
public static bool EndPicking(HideFlagsState state, UnityEngine.Object pickedObject, out ChiselModel model) { model = null; if (state == null || state.hideFlags == null) { return(false); } foreach (var pair in state.hideFlags) { pair.Key.hideFlags = pair.Value; } #if UNITY_EDITOR var sceneVisibilityManager = UnityEditor.SceneVisibilityManager.instance; foreach (var pair in state.hierarchyHidden) { if (pair.Value) { sceneVisibilityManager.Hide(pair.Key, false); } } foreach (var pair in state.hierarchyDisabled) { if (pair.Value) { sceneVisibilityManager.DisablePicking(pair.Key, false); } } foreach (var pair in state.rendererOff) { pair.Key.forceRenderingOff = pair.Value; } s_IgnoreVisibility = false; EndDrawModeForCamera(); #endif if (object.Equals(pickedObject, null)) { return(false); } if (state.generatedComponents == null) { return(false); } bool pickedGeneratedComponent = false; foreach (var pair in state.generatedComponents) { if (pickedObject == pair.Key) { model = pair.Value; pickedGeneratedComponent = true; break; } } return(pickedGeneratedComponent); }
public static HideFlagsState BeginPicking(GameObject[] ignoreGameObjects) { var state = new HideFlagsState() { generatedComponents = new Dictionary <UnityEngine.GameObject, CSGModel>(), hideFlags = new Dictionary <UnityEngine.GameObject, HideFlags>() }; foreach (var model in CSGModelManager.GetAllModels()) { if (!model.generatedMeshes) { continue; } var renderers = model.generatedMeshes.GetComponentsInChildren <Renderer>(); if (renderers != null) { foreach (var renderer in renderers) { state.generatedComponents[renderer.gameObject] = model; } } var colliders = model.generatedMeshes.GetComponentsInChildren <Collider>(); if (colliders != null) { foreach (var collider in colliders) { state.generatedComponents[collider.gameObject] = model; } } } if (state.generatedComponents != null) { foreach (var pair in state.generatedComponents) { var gameObject = pair.Key; var model = pair.Value; state.hideFlags[gameObject] = gameObject.hideFlags; if (ignoreGameObjects != null && ArrayUtility.Contains(ignoreGameObjects, model.gameObject)) { gameObject.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy; } else { gameObject.hideFlags = HideFlags.None; } } } return(state); }
public static HideFlagsState BeginPicking() { var state = new HideFlagsState() { generatedComponents = new Dictionary <UnityEngine.GameObject, ChiselModel>(), hideFlags = new Dictionary <UnityEngine.Object, HideFlags>() }; foreach (var model in models) { if (!model.GeneratedDataContainer) { continue; } var renderers = model.GeneratedDataContainer.GetComponentsInChildren <Renderer>(); if (renderers != null) { foreach (var renderer in renderers) { state.generatedComponents[renderer.gameObject] = model; } } var colliders = model.GeneratedDataContainer.GetComponentsInChildren <Collider>(); if (colliders != null) { foreach (var collider in colliders) { state.generatedComponents[collider.gameObject] = model; } } } if (state.generatedComponents != null) { foreach (var component in state.generatedComponents.Keys) { var gameObject = component.gameObject; var transform = component.transform; state.hideFlags[gameObject] = gameObject.hideFlags; state.hideFlags[transform] = transform.hideFlags; state.hideFlags[component] = component.hideFlags; gameObject.hideFlags = HideFlags.None; transform.hideFlags = HideFlags.None; component.hideFlags = HideFlags.None; } } return(state); }
public static bool EndPicking(HideFlagsState state, UnityEngine.Object pickedObject, out ChiselModel model) { model = null; if (state == null || state.hideFlags == null) { return(false); } foreach (var pair in state.hideFlags) { pair.Key.hideFlags = pair.Value; } if (object.Equals(pickedObject, null)) { return(false); } if (state.generatedComponents == null) { return(false); } bool pickedGeneratedComponent = false; foreach (var pair in state.generatedComponents) { if (pickedObject == pair.Key) { model = pair.Value; pickedGeneratedComponent = true; break; } } return(pickedGeneratedComponent); }
public static HideFlagsState BeginPicking() { var state = new HideFlagsState() { generatedComponents = new Dictionary <UnityEngine.GameObject, ChiselModel>(), hideFlags = new Dictionary <UnityEngine.Object, HideFlags>(), #if UNITY_EDITOR rendererOff = new Dictionary <Renderer, bool>(), hierarchyHidden = new Dictionary <UnityEngine.GameObject, bool>(), hierarchyDisabled = new Dictionary <UnityEngine.GameObject, bool>(), #endif }; #if UNITY_EDITOR var sceneVisibilityManager = UnityEditor.SceneVisibilityManager.instance; #endif foreach (var model in models) { if (!IsValidModelToBeSelected(model)) { continue; } var renderers = model.generated.renderables; if (renderers != null) { foreach (var renderer in renderers) { if (renderer == null || !renderer.container) { continue; } state.generatedComponents[renderer.container] = model; #if UNITY_EDITOR if (renderer.meshRenderer.forceRenderingOff) { state.rendererOff[renderer.meshRenderer] = true; renderer.meshRenderer.forceRenderingOff = false; } #endif } } } if (state.generatedComponents != null) { foreach (var component in state.generatedComponents.Keys) { var gameObject = component.gameObject; var transform = component.transform; state.hideFlags[gameObject] = gameObject.hideFlags; state.hideFlags[transform] = transform.hideFlags; state.hideFlags[component] = component.hideFlags; gameObject.hideFlags = HideFlags.None; transform.hideFlags = HideFlags.None; component.hideFlags = HideFlags.None; #if UNITY_EDITOR state.hierarchyHidden[gameObject] = sceneVisibilityManager.IsHidden(gameObject); if (state.hierarchyHidden[gameObject]) { sceneVisibilityManager.Show(gameObject, false); } state.hierarchyDisabled[gameObject] = sceneVisibilityManager.IsPickingDisabled(gameObject); if (state.hierarchyDisabled[gameObject]) { sceneVisibilityManager.EnablePicking(gameObject, false); } #endif } } return(state); }