• 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
Question by Dreamer · May 27, 2011 at 02:31 AM · stringdialogue

string problem

I am doing dialogues for RPG. These dialogues are stored in String arrays.

To simply the question:

 var name:string="Lucy";
 var dialogue:string;
 
 print("hello Lucy");
 print(dialogue);

I want above to display same output. The problem is I don't initialize it by dialogue="hello" +Lucy; in script. Instead, I need give the value in Inspector, if I give dialogue the value: "hello" +dialogue The print output will simply be the same "hello" +dialogue not hello Lucy

How to achieve this?


Add: I am using this dialogue system made by others: http://kimmonsdesign.com/node/21

For those who don't know about it, it is a useful tool to make dialogues in game. (It can also do conversations similar to Mass Effect) The only problem is the dialogue content is fixed (defined in string arrays). And I am trying to find a way to allow it to be dynamic, that can take variables and affect the dialogue content.


(Btw, this new UnityAnswers is really buggy n poor quality. I miss the one before...oh. it was so perfect)

Comment

People who like this

0 Show 0
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

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by GlennHeckman · May 27, 2011 at 02:37 AM

Your phrasing of the question is odd. For starters, your variable types should be like this (Capital "S" in the variable type declaration):

 var name:String = "Lucy";
 var dialogue:String;
 
 function Start()
 {
     print(dialogue + name);
     // Should give you "whateverYouTypeInTheInspector Lucy"
 }
Comment

People who like this

0 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 Dreamer · May 27, 2011 at 02:40 AM 0
Share

It's not a beginner's question. If you ever doing dialogues for a PRG. You will understand what I mean.

avatar image GlennHeckman · May 27, 2011 at 02:47 AM 0
Share

Perhaps if your question and title were more clear, I wouldn't have mistaken it for a "beginners question".

avatar image Dreamer · May 27, 2011 at 03:07 AM 0
Share

You are right. And due to my experience, title that looks simpler will attract more people to click in and read the questions. lol

avatar image

Answer by aldonaletto · May 27, 2011 at 02:40 AM

If you're trying to put an expression in the Inspector field, it will not work! Use expressions in the code instead:

  print(dialogue+" "+name)

This way you can define the name and the phrase separetelly in the Inspector. And I agree: this new UnitAnswers sucks!

Comment

People who like this

0 Show 1 · 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 aldonaletto · May 27, 2011 at 02:47 AM 0
Share

Oops! I mean separately, not separetelly!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Execute String as Code Line? 1 Answer

String.Remove not working 1 Answer

Ignoring/not displaying text/numbers in string if surrounded with (), [] or <>? 1 Answer

Modifying Brackeys' dialogue system for questions/different dialogue "paths"? 1 Answer

Problems with simple dialogue 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