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 /
This question was closed Sep 28, 2015 at 06:49 AM by RedDevil for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by RedDevil · Sep 27, 2015 at 12:58 PM · gameobjectinstantiatespritepositiontext

Instantiate a GameObject at a position specific to an element that was found in a text

Hello! I am currently trying to create a chat using Unity. I am trying to instantiate emoticons at the position that the emoticon symbol was found but I am having to luck as of yet. I am correctly identifying the emoticons but I cannot instantiate them at the position the emoticon symbols were found. Please help me! Thank you!

 foreach (string item in EmojiStringList)
 {                  
     if (usr.GetComponentInChildren<Text>().text.Contains(item))
     {
         switch (item)
         {
             case "^_^":
             {
                 usr.GetComponentInChildren<Text>().text.Replace(item, string.Empty);
                 GameObject emo = Instantiate(emoji[0], position, Quaternion.identity) as GameObject;
                 emo.transform.SetParent(usr.transform, false);
                 break;
             }
         }
     }
 }

Comment
Add comment · Show 2
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 Priyanshu · Sep 27, 2015 at 01:26 PM 0
Share

I have not tried it yet. But you try to instantiate emoticon at the end of 'Text' component.

For example: If user inputs - " Wassup RedDevil ^_^".

  1. Delete ^_^

  2. Text left "Wassup RedDevil".

  3. Find the position of '.' after string. And instantitae you emote their.

  4. Finding the position of dot will depend on you text anchors and position.

  5. If user wants to continue after message. For example "Wassup RedDevil ^_^ Got your answer yet?"

  6. you instantitae another Text object starting from the right of emote.

  7. All this can be easy if there is a method to find position of words inside TExt object.

avatar image RedDevil Priyanshu · Sep 27, 2015 at 01:40 PM 0
Share

well you told me what i already know... I don't need to find the position of "." because i already am searching for the position of "item". I already know the Y and Z I want the emoticon to be instantiated ... the problem is I have no idea how to find the X relative to "item" .

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Rostam24 · Sep 27, 2015 at 02:38 PM

I think you can use quad inside of rich text for this. See also the documentation for rich text: http://docs.unity3d.com/Manual/StyledText.html

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

36 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

Related Questions

Creating instance of GameObject(Holding component) at same location as object that holds the script 1 Answer

Keep instantiated GameObject's position while parenting it to another GameObject 3 Answers

How do I instantiate same tag/name GameObjects with an array 1 Answer

Adjacent Placement of Objects according to varying height 0 Answers

Change default sprite position when dragged into Hierarchy 1 Answer


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