void OnEnable()
    {
        if( mainCamera == null )
        {
            mainCamera = Camera.main;
            if( mainCamera == null )
            {
                Debug.LogError( "dfFollowObject component is unable to determine which camera is the MainCamera", gameObject );
                this.enabled = false;
                return;
            }
        }

        myControl = GetComponent<dfControl>();
        if( myControl == null )
        {
            Debug.LogError( "No dfControl component on this GameObject: " + gameObject.name, gameObject );
            this.enabled = false;
        }

        if( myControl == null || attach == null )
        {
            Debug.LogWarning( "Configuration incomplete: " + this.name );
            this.enabled = false;
            return;
        }

        controlTransform = myControl.transform;
        followTransform = attach.transform;

        // Obtain a reference to the dfGUIManager rendering the control
        manager = myControl.GetManager();

        dfFollowObjectSorter.Register( this );
    }
    void OnEnable()
    {
        if (mainCamera == null)
        {
            mainCamera = Camera.main;
            if (mainCamera == null)
            {
                Debug.LogError("dfFollowObject component is unable to determine which camera is the MainCamera", gameObject);
                this.enabled = false;
                return;
            }
        }

        myControl = GetComponent <dfControl>();
        if (myControl == null)
        {
            Debug.LogError("No dfControl component on this GameObject: " + gameObject.name, gameObject);
            this.enabled = false;
        }

        if (myControl == null || attach == null)
        {
            Debug.LogWarning("Configuration incomplete: " + this.name);
            this.enabled = false;
            return;
        }

        controlTransform = myControl.transform;
        followTransform  = attach.transform;

        // Obtain a reference to the dfGUIManager rendering the control
        manager = myControl.GetManager();

        dfFollowObjectSorter.Register(this);
    }
Ejemplo n.º 3
0
    private Vector2 raycast(Ray ray)
    {
        var corners = control.GetCorners();
        var plane   = new Plane(corners[0], corners[1], corners[3]);

        var distance = 0f;

        plane.Raycast(ray, out distance);

        var hitPoint = ray.GetPoint(distance);
        var relative = (hitPoint - corners[0]).Scale(1, -1, 0) / control.GetManager().PixelsToUnits();

        return(relative);
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes any variables or game state before the game starts.
 /// </summary>
 public void Awake()
 {
     // Get joystick control
     DFControl = GetComponent <dfControl> ();
     // Get GUI manager
     DFGUIManager = DFControl.GetManager();
     // Choose input handler
                             #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY
     CurrentInputHandler = TouchInputHandler;
                             #endif
                             #if UNITY_EDITOR || UNITY_WEBPLAYER || UNITY_STANDALONE
     CurrentInputHandler = MouseInputHandler;
                             #endif
     if (IsRemoteTesting)
     {
         CurrentInputHandler = TouchInputHandler;
     }
 }
Ejemplo n.º 5
0
    IEnumerator hideWindow( dfControl window )
    {
        busy = true;
        isVisible = false;

        window.IsVisible = true;
        window.GetManager().BringToFront( window );

        var opacity = new dfAnimatedFloat( 1f, 0f, 0.33f );
        while( opacity > 0.05f )
        {
            window.Opacity = opacity;
            yield return null;
        }

        window.Opacity = 0f;

        busy = false;
    }
Ejemplo n.º 6
0
    IEnumerator showWindow( dfControl window )
    {
        isVisible = true;
        busy = true;

        window.IsVisible = true;
        window.GetManager().BringToFront( window );

        var opacity = new dfAnimatedFloat( 0f, 1f, 0.33f );
        while( opacity < 0.95f )
        {
            window.Opacity = opacity;
            yield return null;
        }

        window.Opacity = 1f;

        busy = false;
        isVisible = true;
    }
    IEnumerator hideWindow(dfControl window)
    {
        busy      = true;
        isVisible = false;

        window.IsVisible = true;
        window.GetManager().BringToFront(window);

        var opacity = new dfAnimatedFloat(1f, 0f, 0.33f);

        while (opacity > 0.05f)
        {
            window.Opacity = opacity;
            yield return(null);
        }

        window.Opacity = 0f;

        busy = false;
    }
    IEnumerator showWindow(dfControl window)
    {
        isVisible = true;
        busy      = true;

        window.IsVisible = true;
        window.GetManager().BringToFront(window);

        var opacity = new dfAnimatedFloat(0f, 1f, 0.33f);

        while (opacity < 0.95f)
        {
            window.Opacity = opacity;
            yield return(null);
        }

        window.Opacity = 1f;

        busy      = false;
        isVisible = true;
    }
Ejemplo n.º 9
0
 public void Start()
 {
     this.control = GetComponent<dfControl>();
     this.manager = control.GetManager();
 }
		/// <summary>
		/// Initializes any variables or game state before the game starts.
		/// </summary>
		public void Awake ()
		{
				// Get joystick control
				DFControl = GetComponent<dfControl> ();
				// Get GUI manager
				DFGUIManager = DFControl.GetManager ();
				// Choose input handler
				#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY
				CurrentInputHandler = TouchInputHandler;
				#endif
				#if UNITY_EDITOR || UNITY_WEBPLAYER || UNITY_STANDALONE
				CurrentInputHandler = MouseInputHandler;
				#endif
				if (IsRemoteTesting) {
						CurrentInputHandler = TouchInputHandler;
				}
		}