Hi
I have this error on Unity 5.2.3:
Assets/Scripts/Controls/TouchControl.cs(34,79): error CS1061: Type UnityEngine.GameObject' does not contain a definition for
collider’ and no extension method collider' of type
UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?)
And the code what cause this error is:
if( ControlInput.GetStringButton( j ).collider.Raycast( ray, out hit, Mathf.Infinity ) )
Whole code is:
using UnityEngine;
using System.Collections;
public class TouchControl : MonoBehaviour
{
#if !UNITY_EDITOR && ( UNITY_IPHONE || UNITY_ANDROID )
ControlInput ControlInput;
bool[] StringChanges = new bool[ ControlInput.NumStrings ];
//Use this for initialization
void Start()
{
ControlInput = GetComponent<ControlInput>();
}
void Update()
{
for( int i = 0; i < ControlInput.NumStrings; ++i )
{
StringChanges[ i ] = false;
}
for( int i = 0; i < Input.touchCount; ++i )
{
Touch touch = Input.GetTouch( i );
if( touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary )
{
Ray ray = Camera.main.ScreenPointToRay( touch.position );
RaycastHit hit;
for( int j = 0; j < ControlInput.NumStrings; ++j )
{
if( ControlInput.GetStringButton( j ).collider.Raycast( ray, out hit, Mathf.Infinity ) )
{
StringChanges[ j ] = true;
}
}
}
}
for( int i = 0; i < ControlInput.NumStrings; ++i )
{
ControlInput.OnStringChange( i, StringChanges[ i ] );
}
}
#endif
}
Help me!