Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by buxton4life · Jul 30, 2012 at 08:18 PM · iostouchguitexturetransformsz

Altering Z position of guiTexture through code IOS?

Just wondering why this code does not work, I am trying to move the guiTextures z position from 3 to 0, so the other guiTexture (GUITexture[1]) appears in front of this one when the user taps the screen. Any help would be much appreciated!

 var myTextures : GUITexture[] = new GUITexture[3];

 function Update(){
 for (var evt : Touch in Input.touches) 

  { 
  var ft = myTextures[0].HitTest(Input.mousePosition);
  var ft2 = myTextures[1].HitTest(Input.mousePosition);
  var ft3 = myTextures[2].HitTest(Input.mousePosition);
 
  if (evt.phase == TouchPhase.Stationary) 

  { 

   if(ft){ 

   myTextures[0].transform.position = new Vector3(0.5, 0.5, 0);
 
   }
   if(ft2){

        ......./

   }
   if(ft3){

       ......./

   }
   }
   }  
  }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by ScroodgeM · Jul 30, 2012 at 09:55 PM

may be you need to use 'evt.position' instead of 'Input.mousePosition' ?

bonus:

Toucher.cs

using UnityEngine;
using System.Collections;
public class Toucher : MonoBehaviour
{
    public GUITexture[] myTextures;
    void Update()
    {
        foreach (Touch evt in Input.touches)
        {
            for (int i = 0; i < myTextures.Length; i++)
            {
                Vector3 position = myTextures[i].transform.position;
                position.z = myTextures[i].HitTest(evt.position) ? 3f : 0f;
                myTextures[i].transform.position = position;
            }
        }
    }
}
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image buxton4life · Jul 31, 2012 at 07:42 AM 0
Share

cheers for the reply, the actual tap bit of the code works fine. I changed transform to destroy and it successfully destroys when tapped. But when I use transform.position it doesn't seem to do anything?

avatar image ScroodgeM · Jul 31, 2012 at 08:04 AM 0
Share

i'd explain answer

avatar image buxton4life · Aug 01, 2012 at 10:22 AM 0
Share

Cheers scroodge you nailed it!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

move a gameobject from a GUITexture 0 Answers

TWO GUI texture that doesn't work together 0 Answers

How to use the joystick to control the character 3 Answers

Calling Function in other Script via Touch => iOS Crash 1 Answer

Android touch and drag GUItexture problem 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges