private void MigrateBoxDisplay(BoundsControl control, BoundingBox box) { BoxDisplayConfiguration config = EnsureConfiguration(control.BoxDisplayConfig); config.BoxMaterial = box.BoxMaterial; config.BoxGrabbedMaterial = box.BoxGrabbedMaterial; config.FlattenAxisDisplayScale = box.FlattenAxisDisplayScale; control.BoxDisplayConfig = config; }
private void MigrateBoxDisplay(BoundsControl control, BoundingBox box, string configAssetDirectory) { BoxDisplayConfiguration config = ScriptableObject.CreateInstance <BoxDisplayConfiguration>(); config.BoxMaterial = box.BoxMaterial; config.BoxGrabbedMaterial = box.BoxGrabbedMaterial; config.FlattenAxisDisplayScale = box.FlattenAxisDisplayScale; AssetDatabase.CreateAsset(config, GenerateUniqueConfigName(configAssetDirectory, box.gameObject, "BoxDisplayConfiguration")); control.BoxDisplayConfig = config; }
private void MigrateBoxDisplay(BoundsControl control, BoundingBox box) { List <string> propertyPaths = new List <string> { "boxMaterial", "boxGrabbedMaterial", "flattenAxisDisplayScale" }; BoxDisplayConfiguration config = EnsureConfiguration(control.gameObject, control.BoxDisplayConfig, HasPropertyOverrides(box, propertyPaths)); config.BoxMaterial = box.BoxMaterial; config.BoxGrabbedMaterial = box.BoxGrabbedMaterial; config.FlattenAxisDisplayScale = box.FlattenAxisDisplayScale; control.BoxDisplayConfig = config; }
/// <summary> /// Tests configuring every property of bounds control in edit mode /// </summary> public void TestConfiguration() { GameObject testCube = GameObject.CreatePrimitive(PrimitiveType.Cube); int testInstanceId = testCube.GetInstanceID(); GameObject childSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); var collider = childSphere.AddComponent <BoxCollider>(); GameObject textObj = new GameObject(); textObj.transform.parent = testCube.transform; var textMesh = textObj.AddComponent <TextMesh>(); childSphere.transform.parent = testCube.transform; var boundsControl = testCube.AddComponent <BoundsControl>(); boundsControl.Target = childSphere; boundsControl.BoundsOverride = collider; boundsControl.CalculationMethod = BoundsCalculationMethod.ColliderOverRenderer; boundsControl.BoundsControlActivation = BoundsControlActivationType.ActivateByProximityAndPointer; boundsControl.FlattenAxis = FlattenModeType.FlattenAuto; boundsControl.BoxPadding = Vector3.one; // debug properties boundsControl.DebugText = textMesh; boundsControl.HideElementsInInspector = false; // box display List <string> assetsToDestroy = new List <string>(); BoxDisplayConfiguration boxDisplayConfig = ScriptableObject.CreateInstance <BoxDisplayConfiguration>(); string path = GeneratePath("BoxDisplay", testInstanceId); assetsToDestroy.Add(path); AssetDatabase.CreateAsset(boxDisplayConfig, path); var testMaterial = new Material(Shader.Find("Specular")); boxDisplayConfig.BoxMaterial = testMaterial; boxDisplayConfig.BoxGrabbedMaterial = testMaterial; boxDisplayConfig.FlattenAxisDisplayScale = 5.0f; boundsControl.BoxDisplayConfig = boxDisplayConfig; // links LinksConfiguration linksConfig = ScriptableObject.CreateInstance <LinksConfiguration>(); path = GeneratePath("Links", testInstanceId); assetsToDestroy.Add(path); AssetDatabase.CreateAsset(linksConfig, path); linksConfig.WireframeMaterial = testMaterial; linksConfig.WireframeEdgeRadius = 1.0f; linksConfig.WireframeShape = WireframeType.Cylindrical; linksConfig.ShowWireFrame = false; boundsControl.LinksConfig = linksConfig; // scale handles ScaleHandlesConfiguration scaleConfig = ScriptableObject.CreateInstance <ScaleHandlesConfiguration>(); path = GeneratePath("ScaleHandles", testInstanceId); assetsToDestroy.Add(path); AssetDatabase.CreateAsset(scaleConfig, path); scaleConfig.HandleSlatePrefab = childSphere; scaleConfig.ShowScaleHandles = true; scaleConfig.HandleMaterial = testMaterial; scaleConfig.HandleGrabbedMaterial = testMaterial; scaleConfig.HandlePrefab = testCube; scaleConfig.HandleSize = 0.05f; scaleConfig.ColliderPadding = Vector3.one; scaleConfig.DrawTetherWhenManipulating = false; scaleConfig.HandlesIgnoreCollider = collider; boundsControl.ScaleHandlesConfig = scaleConfig; // rotation handles RotationHandlesConfiguration rotationHandles = ScriptableObject.CreateInstance <RotationHandlesConfiguration>(); path = GeneratePath("RotationHandles", testInstanceId); assetsToDestroy.Add(path); AssetDatabase.CreateAsset(rotationHandles, path); rotationHandles.RotationHandlePrefabColliderType = HandlePrefabCollider.Box; rotationHandles.ShowRotationHandleForX = false; rotationHandles.ShowRotationHandleForY = true; rotationHandles.ShowRotationHandleForZ = true; rotationHandles.HandleMaterial = testMaterial; rotationHandles.HandleGrabbedMaterial = testMaterial; rotationHandles.HandlePrefab = childSphere; rotationHandles.HandleSize = 0.05f; rotationHandles.ColliderPadding = Vector3.zero; rotationHandles.DrawTetherWhenManipulating = false; rotationHandles.HandlesIgnoreCollider = collider; boundsControl.RotationHandlesConfig = rotationHandles; // proximity effect ProximityEffectConfiguration proximityConfig = ScriptableObject.CreateInstance <ProximityEffectConfiguration>(); path = GeneratePath("ProximityEffect", testInstanceId); assetsToDestroy.Add(path); AssetDatabase.CreateAsset(proximityConfig, path); proximityConfig.ProximityEffectActive = true; proximityConfig.ObjectMediumProximity = 0.2f; proximityConfig.ObjectCloseProximity = 0.02f; proximityConfig.FarScale = 10.0f; proximityConfig.MediumScale = 3.0f; proximityConfig.CloseScale = 5.0f; proximityConfig.FarGrowRate = 1.0f; proximityConfig.MediumGrowRate = 0.1f; proximityConfig.CloseGrowRate = 0.5f; boundsControl.HandleProximityEffectConfig = proximityConfig; // clean up created assets foreach (string assetPath in assetsToDestroy) { AssetDatabase.DeleteAsset(assetPath); } // destroy test cube Object.DestroyImmediate(testCube); }