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 jo05099056 · Mar 22, 2018 at 03:28 PM · inputfieldelement

Changing Elements based off an Input Field answer

Long story short, heres the code I'm using. I'm trying to make it if a certain set of words are said, you will get different effects. I'm also using the Elements for the text so I was wondering if there was a way for it to detect what is in the Input Field and changing the element accordingly?

 using System;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityStandardAssets.CrossPlatformInput;
 using UnityStandardAssets.Utility;
 using Random = UnityEngine.Random;
 
 
 public class DebateConversation     : MonoBehaviour {
 
     public GameObject neutral_Nagito;
     public GameObject diffuse_Nagito;
     public GameObject hello_Nagito;
     public GameObject ponder_Nagito;
     public GameObject scold_Nagito;
     public GameObject hmmm_Nagito;
     public GameObject angry_Nagito;
     public GameObject surprised_Nagito;
     public GameObject insane_Nagito;
 
     public InputField Contradiction_Text;
 
 
     public Button NextConv;
     public Button PrevConv;
     public Button Contradict;
     public Canvas Contra_Menu;
 
     public GameObject Ponderosa;
     public GameObject Ponderosa_D;
     public GameObject D_Trigger;
     public Canvas D_Conversation; 
     public Text textbox;
     public UnityStandardAssets.Characters.FirstPerson.FirstPersonController fpc;
     int i, j, testJ;
 
     public string[] speeches;
     public string[] Contradiction_bullet;
 
     void Start () {
         Ponderosa.SetActive (true);
         Contra_Menu.enabled = false;
         neutral_Nagito.SetActive (false);
         diffuse_Nagito.SetActive (false);
         hello_Nagito.SetActive (false);
         ponder_Nagito.SetActive (false);
         scold_Nagito.SetActive (false);
         hmmm_Nagito.SetActive (false);
         angry_Nagito.SetActive (false);
         surprised_Nagito.SetActive (false);
         insane_Nagito.SetActive (false);
 
         Cursor.visible = false;
         Cursor.lockState = CursorLockMode.Locked;
         D_Conversation.enabled = false;
         testJ = j;
 
 
 
 
 
         Button CDTbtn = Contradict.GetComponent<Button>();
         CDTbtn.onClick.AddListener(Contra_TaskOnClick);
 
         Button NXTbtn = NextConv.GetComponent<Button>();
         NXTbtn.onClick.AddListener(Next_TaskOnClick);
 
         Button PREbtn = PrevConv.GetComponent<Button>();
         PREbtn.onClick.AddListener(Prev_TaskOnClick);
     }
 
     // Update is called once per frame
     void Update () {
     }
 
 
 
     void OnTriggerStay(Collider other) {
         Debug.Log (other.name);
         if (other.name == "Detective Ponderosa" && Input.GetKeyDown (KeyCode.E)) {
             Ponderosa.SetActive (false);
             Cursor.visible = false;
             Cursor.lockState = CursorLockMode.Locked;
             fpc.enabled = false;
             D_Conversation.enabled = true;
         }
     }
 
     void Contra_TaskOnClick () {
 
     }
 
     void Next_TaskOnClick () {
 
         i++;
 
     }
 
     void Prev_TaskOnClick () {
 
         i--;    
 
     }    
 
 
 
     void FixedUpdate() {
         string Contradiction_Bullet = Contradiction_Text.text.ToString();
         if (D_Conversation.isActiveAndEnabled) {
             for (int j = 0; j < speeches [i].Length + 1; j++) {
                 textbox.text = speeches [i].Substring (0, j);
                 testJ = j;
             }
 
 
         }
         if ((testJ >= speeches[i].Length) && (Input.GetMouseButtonDown(0))) {
             i++;
         }
 
         if (i == 0) {
             hmmm_Nagito.SetActive (true);
         }
         if (i == 1) {
             hmmm_Nagito.SetActive(false);
             ponder_Nagito.SetActive (true);
         }
         if (i == 2) {
             ponder_Nagito.SetActive (false);
             surprised_Nagito.SetActive (true);
         }
         if (i == 3) {
             if (Contradiction_Bullet == "knife") {
                 i = 7;
             }
         }
         if (i == 4) {
 
         }
         if (i == 5) {
 
         }
         if (i == 6) {
             surprised_Nagito.SetActive (false);
             hmmm_Nagito.SetActive (true);
             i = 0;
         }
         if (i == 7) {
 
         }
         if (i == 8) {
 
         }
         if (i == 9) {
 
         }
         if (i == 10) {
 
         }
 
         if (i == speeches.Length) {
             Ponderosa.SetActive (true);
             Cursor.visible = false;
             Cursor.lockState = CursorLockMode.Locked;
             fpc.enabled = true;
             D_Conversation.enabled = false;
         }
         if ((i == speeches.Length) && (fpc.enabled = true)){
             i=0;
 
         }
     }
 
 
 }
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

75 People are following this question.

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

Related Questions

Playing animation elements not working 2 Answers

How do you Get Variables with 2 or more Elements? 2 Answers

Issue removing element from List 0 Answers

How to save InputField value? 1 Answer

How to prevent Input Field firing End Edit on change of focus? 2 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