Example #1
0
        public override void OnInspectorGUI()
        {
            BoundingBoxTarget bbt = (BoundingBoxTarget)target;

            // See if there's a bounding box yet
            BoundingBoxManipulate bbm = GameObject.FindObjectOfType <BoundingBoxManipulate>();
            AppBar toolbar            = GameObject.FindObjectOfType <AppBar>();

            if (bbm == null || toolbar == null)
            {
                HUXEditorUtils.ErrorMessage(
                    "Couldn't find a bounding box prefab and/or manipulation toolbar in the scene. Bounding box target won't work without them.",
                    AddBoundingBox);
            }

            HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnSelected");
            HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnDeselected");
            bbt.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>(
                "Permitted Operations",
                bbt.PermittedOperations,
                "Default",
                BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag,
                BoundingBoxManipulate.OperationEnum.Drag);

            bbt.ShowAppBar = EditorGUILayout.Toggle("Toolbar Display", bbt.ShowAppBar);


            HUXEditorUtils.SaveChanges(bbt);
        }
        public override void OnInspectorGUI()
        {
            BoundingBoxManipulate bbm = (BoundingBoxManipulate)target;

            GUI.color = HUXEditorUtils.DefaultColor;

            bbm.Target              = (GameObject)EditorGUILayout.ObjectField("Target", bbm.Target, typeof(GameObject), true);
            bbm.ActiveHandle        = (BoundingBoxHandle)EditorGUILayout.ObjectField("Active Handle", bbm.ActiveHandle, typeof(BoundingBoxHandle), true);
            bbm.PhysicsLayer        = EditorGUILayout.IntSlider("Physics / Rendering Layer", bbm.PhysicsLayer, 0, 32);
            bbm.IgnoreLayer         = EditorGUILayout.IntSlider("Ignore Mesh Renderers on this Layer", bbm.IgnoreLayer, 0, 32);
            bbm.DragMultiplier      = EditorGUILayout.Slider("Drag input scale", bbm.DragMultiplier, 0.01f, 20f);
            bbm.RotateMultiplier    = EditorGUILayout.Slider("Rotation input scale", bbm.RotateMultiplier, 0.01f, 20f);
            bbm.ScaleMultiplier     = EditorGUILayout.Slider("Scale input scale", bbm.ScaleMultiplier, 0.01f, 20f);
            bbm.MinScalePercentage  = EditorGUILayout.Slider("Minimum scale per operation", bbm.MinScalePercentage, 0.05f, 1f);
            bbm.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>(
                "Permitted Operations",
                bbm.PermittedOperations,
                "Default",
                BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag,
                BoundingBoxManipulate.OperationEnum.Drag);

            if (!Application.isPlaying)
            {
                bbm.AcceptInput     = EditorGUILayout.Toggle("Accept Input", bbm.AcceptInput);
                bbm.ManipulatingNow = EditorGUILayout.Toggle("Manipulating Now", bbm.ManipulatingNow);
            }

            HUXEditorUtils.SaveChanges(bbm);
        }
Example #3
0
        private void AddBoundingBox()
        {
            BoundingBoxManipulate bbm = GameObject.FindObjectOfType <BoundingBoxManipulate>();
            AppBar toolbar            = GameObject.FindObjectOfType <AppBar>();

            if (bbm == null)
            {
                Object     prefab = AssetDatabase.LoadAssetAtPath(BoundingBoxPrefabPath, typeof(GameObject));
                GameObject clone  = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
                clone.name = prefab.name;
            }
            if (toolbar == null)
            {
                Object     prefab = AssetDatabase.LoadAssetAtPath(ToolbarPrefabPath, typeof(GameObject));
                GameObject clone  = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
                clone.name = prefab.name;
            }
        }
        protected override void OnTapped(GameObject obj, InteractionManager.InteractionEventArgs eventArgs)
        {
            if (Time.time < lastTimeTapped + coolDownTime)
            {
                return;
            }

            lastTimeTapped = Time.time;

            base.OnTapped(obj, eventArgs);

            switch (obj.name)
            {
            case "Remove":
                // Destroy the target object
                GameObject.Destroy(boundingBox.Target);
                // Set our bounding box to null so we'll disappear
                boundingBox = null;
                break;

            case "Adjust":
                // Make the bounding box active so users can manipulate it
                State = AppBarStateEnum.Manipulation;
                break;

            case "Hide":
                // Make the bounding box inactive and invisible
                State = AppBarStateEnum.Hidden;
                break;

            case "Show":
                State = AppBarStateEnum.Default;
                break;

            case "Done":
                State = AppBarStateEnum.Default;
                break;

            default:
                break;
            }
        }
Example #5
0
        public override void OnInspectorGUI()
        {
            BoundingBoxManipulate bbm = (BoundingBoxManipulate)target;

            GUI.color = HUXEditorUtils.DefaultColor;

            bbm.Target = (GameObject)EditorGUILayout.ObjectField("Target", bbm.Target, typeof(GameObject), true);
            //bbm.ActiveHandle = (BoundingBoxHandle)EditorGUILayout.ObjectField("Active Handle", bbm.ActiveHandle, typeof(BoundingBoxHandle), true);

            HUXEditorUtils.BeginSectionBox("Settings");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Bounds method", GUILayout.MaxWidth(100));
            bbm.BoundsCalculationMethod = (BoundingBox.BoundsCalculationMethodEnum)EditorGUILayout.EnumPopup(bbm.BoundsCalculationMethod, GUILayout.MaxWidth(155));
            switch (bbm.BoundsCalculationMethod)
            {
            case BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds:
                HUXEditorUtils.DrawSubtleMiniLabel("Uses all MeshFilters to calculate bounds. This setting is more accurate (especially for flat objects), but will only calculate bounds for mesh-based objects.");
                break;

            case BoundingBox.BoundsCalculationMethodEnum.RendererBounds:
                HUXEditorUtils.DrawSubtleMiniLabel("Uses all Renderers to calculate bounds. This setting is less accurate, but can calculate bounds for objects like particle systems.");
                break;
            }
            EditorGUILayout.EndHorizontal();
            bbm.PhysicsLayer = EditorGUILayout.IntSlider("Physics / Rendering Layer", bbm.PhysicsLayer, 0, 32);
            bbm.IgnoreLayer  = EditorGUILayout.IntSlider("Ignore Mesh Renderers on this Layer", bbm.IgnoreLayer, 0, 32);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Manipulation");
            bbm.DragMultiplier     = EditorGUILayout.Slider("Drag input scale", bbm.DragMultiplier, 0.01f, 20f);
            bbm.RotateMultiplier   = EditorGUILayout.Slider("Rotation input scale", bbm.RotateMultiplier, 0.01f, 20f);
            bbm.ScaleMultiplier    = EditorGUILayout.Slider("Scale input scale", bbm.ScaleMultiplier, 0.01f, 20f);
            bbm.MinScalePercentage = EditorGUILayout.Slider("Minimum scale per operation", bbm.MinScalePercentage, 0.05f, 1f);
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Flattening");
            bbm.FlattenPreference = (BoundingBox.FlattenModeEnum)EditorGUILayout.EnumPopup("Flattening preference", bbm.FlattenPreference);
            switch (bbm.FlattenPreference)
            {
            case BoundingBox.FlattenModeEnum.DoNotFlatten:
                HUXEditorUtils.DrawSubtleMiniLabel("Bounding box will never be flattened no matter how thin the target object gets.");
                break;

            case BoundingBox.FlattenModeEnum.FlattenAuto:
                HUXEditorUtils.DrawSubtleMiniLabel("If an axis drops below the relative % threshold, that axis will be flattened to the specified thickness.");
                bbm.FlattenAxisThreshold   = EditorGUILayout.Slider("Flatten axis threshold %", (bbm.FlattenAxisThreshold * 100), 0.01f, 100f) / 100;
                bbm.FlattenedAxisThickness = EditorGUILayout.Slider("Flattened axis thickness", bbm.FlattenedAxisThickness, 0.001f, 1f);
                if (bbm.BoundsCalculationMethod == BoundingBox.BoundsCalculationMethodEnum.RendererBounds)
                {
                    HUXEditorUtils.WarningMessage("The " + bbm.BoundsCalculationMethod + " method may result in distortion for flattened objects. " + BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds + " method is recommended for this setting.");
                }
                EditorGUILayout.EnumPopup("Current flattened axis: ", bbm.FlattenedAxis);
                break;

            case BoundingBox.FlattenModeEnum.FlattenX:
            case BoundingBox.FlattenModeEnum.FlattenY:
            case BoundingBox.FlattenModeEnum.FlattenZ:
                HUXEditorUtils.DrawSubtleMiniLabel("The selected axis will be flattened to the specified thickness.");
                bbm.FlattenedAxisThickness = EditorGUILayout.Slider("Flattened axis thickness", bbm.FlattenedAxisThickness, 0.001f, 1f);
                if (bbm.BoundsCalculationMethod == BoundingBox.BoundsCalculationMethodEnum.RendererBounds)
                {
                    HUXEditorUtils.WarningMessage("The " + bbm.BoundsCalculationMethod + " method may result in distortion for flattened objects. " + BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds + " method is recommended for this setting.");
                }
                break;
            }
            HUXEditorUtils.EndSubSectionBox();

            bbm.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>(
                "Permitted Operations",
                bbm.PermittedOperations,
                "Default",
                BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag,
                BoundingBoxManipulate.OperationEnum.Drag);

            if (!Application.isPlaying)
            {
                bbm.AcceptInput     = EditorGUILayout.Toggle("Accept Input", bbm.AcceptInput);
                bbm.ManipulatingNow = EditorGUILayout.Toggle("Manipulating Now", bbm.ManipulatingNow);
            }

            HUXEditorUtils.SaveChanges(bbm);
        }