internal override void Start() { base.Start(); graphControl = FindObjectOfType <GraphController>(); go = this.gameObject; goBGhost = go.GetComponent <BGhostObject>(); goCo = goBGhost.GetCollisionObject(); goGhost = (GhostObject)goCo; goParent = go.transform.parent.gameObject; goParentRb = goParent.GetComponent <BRigidBody>(); goParentCo = goParentRb.GetCollisionObject(); if (goCo.CollisionShape is SphereShape) { sphRadius = this.gameObject.GetComponent <BSphereShape>().Radius; // when using a Sphere as CollisionObject } else if (goCo.CollisionShape is BoxShape) { sphRadius = this.gameObject.GetComponent <BBoxShape>().Extents.x; // when using a Box as CollisionObject. Box is assumed to have equal sides. } else { Debug.LogError("GhostObjPiggyBack2: CollisionObject not Sphere or Box. sphRadius will be empty, repulse not working."); } sphRadiusSqr = sphRadius * sphRadius; }
public override void OnInspectorGUI() { BGhostObject obj = (BGhostObject)target; obj.m_collisionFlags = BCollisionObjectEditor.RenderEnumMaskCollisionFlagsField(BCollisionObjectEditor.gcCollisionFlags, obj.m_collisionFlags); obj.m_groupsIBelongTo = BCollisionObjectEditor.RenderEnumMaskCollisionFilterGroupsField(BCollisionObjectEditor.gcGroupsIBelongTo, obj.m_groupsIBelongTo); obj.m_collisionMask = BCollisionObjectEditor.RenderEnumMaskCollisionFilterGroupsField(BCollisionObjectEditor.gcCollisionMask, obj.m_collisionMask); if (GUI.changed) { EditorUtility.SetDirty(obj); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); Undo.RecordObject(obj, "Undo Rigid Body"); } }