Example #1
0
        static bool ValidateConvertTo315()
        {
            GameObject go = Selection.activeGameObject;

            if (go == null)
            {
                return(false);
            }

            QuickRope rope = go.GetComponent <QuickRope>();

            if (rope == null)
            {
                return(false);
            }

            bool isNewest = true;

            for (int i = 0; i < rope.Links.Length; i++)
            {
                if (rope.Links[i].gameObject.GetComponent <ConfigurableJoint>() != null)
                {
                    isNewest = false;
                    break;
                }
            }

            return(!isNewest);
        }
Example #2
0
 public static QuickRope Create(
     Vector3 _position,
     GameObject _prefab,
     float _linkSpacing = 1f,
     float _prefabScale = 0.5f)
 {
     return(QuickRope.Create(_position, Vector3.op_Addition(_position, new Vector3(0.0f, 5f, 0.0f)), _prefab, _linkSpacing, _prefabScale));
 }
        void OnEnable()
        {
            if(checkIfOld && ValidateConvertTo315())
                ConvertTo315();
            
            rope = serializedObject.targetObject as QuickRope;

            sceneGUIDelegates = new System.Action[] { BaseSceneGUI, JointsSceneGUI, BaseSceneGUI };
            inspectorGUIDelegats = new System.Action[] { BaseInspector, LinksInspector, SplineInspector };

            if (rope.Links.Length == 0)
                UpdateRope();

            SplineEditor.ShowInspector = false;
            editMode = EditorPrefs.GetInt("PicoGames_QuickRopes_EditMode", 0);
        }
Example #4
0
        static void ConvertTo315()
        {
            GameObject go   = Selection.activeGameObject;
            QuickRope  rope = go.GetComponent <QuickRope>();

            for (int i = 0; i < rope.Links.Length; i++)
            {
                ConfigurableJoint oldJnt = rope.Links[i].gameObject.GetComponent <ConfigurableJoint>();
                if (oldJnt != null)
                {
                    DestroyImmediate(oldJnt);
                }
            }

            Debug.Log("Update Rope");
        }
Example #5
0
        void OnEnable()
        {
            if (checkIfOld && ValidateConvertTo315())
            {
                ConvertTo315();
            }

            rope = serializedObject.targetObject as QuickRope;

            sceneGUIDelegates    = new System.Action[] { BaseSceneGUI, JointsSceneGUI, BaseSceneGUI };
            inspectorGUIDelegats = new System.Action[] { BaseInspector, LinksInspector, SplineInspector };

            if (rope.Links.Length == 0)
            {
                UpdateRope();
            }

            SplineEditor.ShowInspector = false;
            editMode = EditorPrefs.GetInt("PicoGames_QuickRopes_EditMode", 0);
        }
Example #6
0
        public static QuickRope Create(Vector3 _pointA, Vector3 _pointB, GameObject _prefab, float _linkSpacing = 1.0f, float _prefabScale = 0.5f)
        {
            GameObject ropeObj = new GameObject("Rope");

            ropeObj.transform.position = _pointA;

            QuickRope rope = ropeObj.AddComponent <QuickRope>();

            rope.defaultPrefab = _prefab;

            Vector3 direction = (_pointB - _pointA).normalized;

            rope.Spline.SetControlPoint(1, _pointB, Space.World);
            rope.Spline.SetPoint(1, _pointA + direction, Space.World);
            rope.Spline.SetPoint(2, _pointB - direction, Space.World);

            rope.Generate();
            //rope.Generate();

            return(rope);
        }
Example #7
0
    void Awake()
    {
        rope = GetComponent<QuickRope>();

        if (rope.Spline.IsLooped)
        {
            enabled = false;
            return;
        }

        rope.minLinkCount = minJointCount;

        if (!rope.canResize)
        {
            rope.maxLinkCount = rope.Links.Length + 1;
            rope.canResize = true;

            rope.Generate();
        }

        rope.Links[rope.Links.Length - 1].Rigidbody.isKinematic = true;
    }
Example #8
0
        public static QuickRope Create(
            Vector3 _pointA,
            Vector3 _pointB,
            GameObject _prefab,
            float _linkSpacing = 1f,
            float _prefabScale = 0.5f)
        {
            GameObject gameObject = new GameObject("Rope");

            gameObject.get_transform().set_position(_pointA);
            QuickRope quickRope = (QuickRope)gameObject.AddComponent <QuickRope>();

            quickRope.defaultPrefab = _prefab;
            Vector3 vector3    = Vector3.op_Subtraction(_pointB, _pointA);
            Vector3 normalized = ((Vector3) ref vector3).get_normalized();

            quickRope.Spline.SetControlPoint(1, _pointB, (Space)0);
            quickRope.Spline.SetPoint(1, Vector3.op_Addition(_pointA, normalized), (Space)0);
            quickRope.Spline.SetPoint(2, Vector3.op_Subtraction(_pointB, normalized), (Space)0);
            quickRope.Generate();
            return(quickRope);
        }
Example #9
0
 void Start()
 {
     rope = gameObject.GetComponent<QuickRope>();
 }