Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            IKChain2D chain = m_Solver.GetChain(0);

            serializedObject.Update();
            EditorGUILayout.PropertyField(m_EffectorProperty, Contents.effectorLabel);
            EditorGUILayout.PropertyField(m_TargetProperty, Contents.targetLabel);
            EditorGUILayout.IntSlider(m_TransformCountProperty, 0, IKUtility.GetMaxChainCount(chain), Contents.chainLengthLabel);
            EditorGUILayout.PropertyField(m_IterationsProperty, Contents.iterationsLabel);
            EditorGUILayout.PropertyField(m_ToleranceProperty, Contents.toleranceLabel);

            DrawCommonSolverInspector();

            serializedObject.ApplyModifiedProperties();
        }
        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);
        }