Exemple #1
0
        private void OnEnable()
        {
            m_Solver = target as FabrikSolver2D;
            var chainProperty = serializedObject.FindProperty("m_Chain");

            m_TargetProperty         = chainProperty.FindPropertyRelative("m_TargetTransform");
            m_EffectorProperty       = chainProperty.FindPropertyRelative("m_EffectorTransform");
            m_TransformCountProperty = chainProperty.FindPropertyRelative("m_TransformCount");
            m_IterationsProperty     = serializedObject.FindProperty("m_Iterations");
            m_ToleranceProperty      = serializedObject.FindProperty("m_Tolerance");
        }
        public void Setup()
        {
            go = new GameObject();
            var child1GO = new GameObject();

            child1GO.transform.parent = go.transform;

            var child2GO = new GameObject();

            child2GO.transform.parent = child1GO.transform;

            var child3GO = new GameObject();

            child3GO.transform.parent = child2GO.transform;

            targetGO = new GameObject();
            targetGO.transform.parent = child3GO.transform;

            go.transform.position       = Vector3.zero;
            child1GO.transform.position = new Vector3(1.0f, 0.0f, 0.0f);
            child2GO.transform.position = new Vector3(3.0f, 0.0f, 0.0f);
            child3GO.transform.position = new Vector3(6.0f, 0.0f, 0.0f);
            targetGO.transform.position = new Vector3(10.0f, 0.0f, 0.0f);

            ikGO    = new GameObject();
            manager = ikGO.AddComponent <IKManager2D>();
            var lsGO = new GameObject();

            solver = lsGO.AddComponent <FabrikSolver2D>();
            lsGO.transform.parent = ikGO.transform;

            effectorGO = new GameObject();
            effectorGO.transform.parent = solver.transform;

            chain                = solver.GetChain(0);
            chain.target         = targetGO.transform;
            chain.effector       = effectorGO.transform;
            chain.transformCount = 5;

            solver.Initialize();

            manager.AddSolver(solver);
        }