Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by dom_cobb_22 · May 16, 2017 at 04:31 PM · event triggering

EventTrigger do not work after my Intro script

Hello. I have an FPS project with simple Inventory system, that possible to put object to Inventory and use objects from Inventory when I turn camera on some UsableObject and click on item in the Inventory. Click on item realized through PointerClick in EventTrigger. Item itself is UI element, added from prefabs, stored in Array in GameManager and Attached (through the script when I put object at runtime) to Inventory_Panel, that have Grid order.

Everythings work allright, if I do not use my Intro script. But if is... Object in Inventory is no more clickable. Nothing to run. Method do not run at all.

Whats do Intro script: Just Deactivate FPS Controller and LookAt for time its run. Show and Hide some Intro_Panels and itself Texts. Run some animations for Texts, Lights, And Door GameObject. Show menu with Buttons. And give back FPS Controller and LookAt scripts, then I click the Play_Button.

 public class Intro : MonoBehaviour {
 
     public GameObject introPanel;
     public Animator introPanelAnimator;
     public GameObject introText1;
     public GameObject introText2;
 
     public FirstPersonController FPSController;
 
     public GameObject mainMenuPanel;
     public Animator mainMenuAnimator;
     public Animator lightsAnimator;
 
     public Door door;
     public GameObject crosshair;
     public LookAt lookAt;
     
 
     void Start ()
     {
         FPSController.enabled = false;
         lookAt.enabled = false;
         crosshair.SetActive(false);
         mainMenuPanel.SetActive(false);
         
         ShowBlackScreen();
         Invoke("ShowFirstScreen", 1f);
         Invoke("ShowBlackScreen", 4f);
         Invoke("ShowSecondScreen", 5f);
         Invoke("ShowBlackScreen", 8f);
         Invoke("HideIntroPanel", 9f);
 
         // animate lights turns on
         Invoke("LightsIntro", 9f);
 
         // run door animation
         Invoke("MoveDoor", 14f);
 
         // run menu menu animation
         Invoke("ShowMainMenu", 17f);
     }
 
     private void ShowBlackScreen()
     {
         introPanel.SetActive(true);
         introText1.SetActive(false);
         introText2.SetActive(false);
     }
 
     private void ShowFirstScreen()
     {
         introText1.SetActive(true);
         introText2.SetActive(false);
     }
 
     private void ShowSecondScreen()
     {
         introText1.SetActive(false);
         introText2.SetActive(true);
     }
 
     private void HideIntroPanel()
     {
         introPanelAnimator.SetTrigger("IntroPanelFadeOut");
     }
 
     private void LightsIntro()
     {
         lightsAnimator.SetTrigger("LightsIntro");
     }
 
     private void MoveDoor()
     {
         door.MoveDoor();
     }
 
     private void ShowMainMenu()
     {
         mainMenuPanel.SetActive(true);
         mainMenuAnimator.SetTrigger("TextFadeIn");
     }
 
     public void StartGame()
     {
         mainMenuPanel.SetActive(false);
         crosshair.SetActive(true);
         FPSController.enabled = true;
         lookAt.enabled = true;
     }
 
     public void QuitGame()
     {
         Application.Quit();
     }
     
 }

LookAt is script that cast a ray and change Cursor type depends on UsableObject or usual towards to camera. And looking for ButtonPressed for Use something.

So why this Intro script corrupted my TriggerEvent logic? Do you have some thoughts, guys?

P.S. ItemSlot logic. MoveDoor method - it is what stopping work.

 public class PickableObject : MonoBehaviour {
 
     public int poItemId;
     private GameObject gameManager;
 
     private void Start()
     {
         gameManager = GameObject.Find("GameManager");
     }
 
     private int GetUOItemId()
     {
         int uoItemId = 0;
         RaycastHit hit;
         if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 1.5f))
         {
             if (hit.transform.tag == "Usable") // replace to if has component
             {
                 uoItemId = hit.transform.GetComponent<UsableObject>().uoItemId;
             }
         }
 
         return uoItemId;
     }
 
     public void MoveDoor()
     {
         if (GetUOItemId() == 1)
         {
             gameManager.GetComponent<Door>().MoveDoor();
         }
         else
         {
             print("This object cannot be used here.");
         }
     }
 
 }

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to use PointerEnter on 3D Object 1 Answer

Custom Event System, Coroutines, Callbacks? 1 Answer

Hard time getting mouse click to work 2 Answers

UI Buttons to work continuously when pressed and held for sometime 1 Answer

Double Jump With UI BUTTONS; 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