@@ -2034,6 +2034,45 @@ public IEnumerator PerAxisHandleFlattenTest([ValueSource("perAxisHandleTestData"
2034
2034
yield return null ;
2035
2035
}
2036
2036
2037
+ /// <summary>
2038
+ /// Test for verifying that per axis handles are properly switched off/on when
2039
+ /// FlattenAuto mode is used.
2040
+ /// </summary>
2041
+ [ UnityTest ]
2042
+ public IEnumerator FlattenAutoTest ( [ ValueSource ( "perAxisHandleTestData" ) ] PerAxisHandleTestData testData )
2043
+ {
2044
+ // test flatten mode of per axis handle
2045
+ var boundsControl = InstantiateSceneAndDefaultBoundsControl ( ) ;
2046
+ yield return VerifyInitialBoundsCorrect ( boundsControl ) ;
2047
+ boundsControl . TranslationHandlesConfig . ShowHandleForX = true ; // make sure translation handle test handle is enabled for per axis tests
2048
+
2049
+ // Make cube very flat on X axis.
2050
+ boundsControl . transform . localScale = new Vector3 ( 0.01f , 1f , 1f ) ;
2051
+ boundsControl . HideElementsInInspector = false ;
2052
+
2053
+ // cache rig root for verifying that we're not recreating the rig on config changes
2054
+ GameObject rigRoot = boundsControl . transform . Find ( "rigRoot" ) . gameObject ;
2055
+ Assert . IsNotNull ( rigRoot , "rigRoot couldn't be found" ) ;
2056
+
2057
+ // get handle and make sure it's active per default
2058
+ Transform handle = rigRoot . transform . Find ( testData . handleName + "_0" ) ;
2059
+ Assert . IsNotNull ( handle , "couldn't find handle" ) ;
2060
+ Assert . IsTrue ( handle . gameObject . activeSelf , "handle wasn't enabled by default" ) ;
2061
+
2062
+ // Set FlattenModeType to FlattenAuto
2063
+ boundsControl . FlattenAxis = FlattenModeType . FlattenAuto ;
2064
+
2065
+ Assert . IsFalse ( handle . gameObject . activeSelf , "handle wasn't disabled when FlattenAuto was used" ) ;
2066
+ Assert . IsNotNull ( rigRoot , "rigRoot got destroyed while configuring bounds control during runtime" ) ;
2067
+
2068
+ // unflatten the control again and make sure handle gets activated accordingly
2069
+ boundsControl . FlattenAxis = FlattenModeType . DoNotFlatten ;
2070
+ Assert . IsTrue ( handle . gameObject . activeSelf , "handle wasn't enabled on unflatten" ) ;
2071
+ Assert . IsNotNull ( rigRoot , "rigRoot got destroyed while configuring bounds control during runtime" ) ;
2072
+
2073
+ yield return null ;
2074
+ }
2075
+
2037
2076
/// <summary>
2038
2077
/// Test for verifying changing the per axis handle prefabs during runtime
2039
2078
/// and making sure the entire rig won't be recreated
0 commit comments