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 /
avatar image
0
Question by BigToe · Dec 01, 2010 at 12:35 AM · orderhashtablecreation

Problems with Hashtables and creation order?

I am having some problems initializing and calling my hash table of hash tables. From what I can see I am creating the tables correctly, but when I try to access the hashtable from another script in the start menu, it says that the object reference isn't set.

When the same is called from the other scripts update, everything is fine. So is there a way to prioritize the creation of the hashtable before the other script calls its Start()?

I'm clearly missing something, so if somebody can point me in the right direction, that would be great.

Here's my class with the Hashtable:

using UnityEngine; using System.Collections;

public class PathLibrary : MonoBehaviour {

 public Hashtable thePaths;

 // Use this for initialization
 void Start () {
     thePaths = new Hashtable();
     initPaths();

     Hashtable currentRoute = (Hashtable)thePaths["Path1"];
     Vector3[] thePoints  = (Vector3[])currentRoute["PathPoints"];
     print("First Coord:" + thePoints[0].ToString());

 }

 void initPaths(){

     Hashtable ht = new Hashtable();

     //Path1 Init
     ht = iTween.Hash("PathPoints", new Vector3[]{v3(0,0,10), v3(15,0,40)},"Speed", 2.0f);
     thePaths.Add("Path1", ht);

     //Path2 Init
     ht = iTween.Hash("PathPoints", new Vector3[]{v3(0,0,10), v3(15,0,40)},"Speed", 2.0f);
     thePaths.Add("Path2", ht);

     //Path3 Init
     ht = iTween.Hash("PathPoints", new Vector3[]{v3(0,0,10), v3(15,0,40)},"Speed", 2.0f);
     thePaths.Add("Path3", ht);


     Hashtable currentPath = (Hashtable)thePaths["Path1"];

     print ("The Route Points" + ((Vector3[])currentPath["PathPoints"])[0].ToString());

 }

 Vector3 v3(float x, float y, float z){
     return new Vector3(x,y,z);
 }


}

And here is the class that calls the hashtable

using UnityEngine;

using System.Collections;

public class CallPath : MonoBehaviour {

PathLibrary pathLib;

void Start () { pathLib = GetComponent<PathLibrary>();

 Hashtable currentRoute = (Hashtable)pathLib.thePaths["Path1"];
 Vector3[] thePoints  = (Vector3[])currentRoute["PathPoints"];
 print("First Coord nenenene:" + thePoints[0].ToString());

 /*This causes an error message that reads "NullReferenceException:Object reference
 not set to an instance of an object
 */

}

void Update () {

 Hashtable currentRoute = (Hashtable)pathLib.thePaths["Path1"];
 Vector3[] thePoints  = (Vector3[])currentRoute["PathPoints"];
 print("First Coord nenenene:" + thePoints[0].ToString());

 //This works!!!!

}

}

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

2 Replies

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

Answer by Peter G · Dec 01, 2010 at 12:41 AM

I haven't tested you code, but if all's you need to do call 1 script 1st, then you can put the 1st one in the Awake() method which is called before Start().

Comment
Add comment · Show 2 · 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 BigToe · Dec 01, 2010 at 01:10 AM 0
Share

Thanks so much! I knew it must have been something simple.

avatar image jt78 · Feb 23, 2011 at 07:51 PM 0
Share

Thank You! You just fixed a problem that I've been trying to fix for 4 hours :)

avatar image
0

Answer by pixelplacement · Dec 03, 2010 at 07:54 AM

Would this help you? http://pixelplacement.com/2010/12/03/visual-editor-for-itween-motion-paths/

Comment
Add comment · 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 BigToe · Dec 04, 2010 at 06:31 AM 0
Share

Wow! That is really a fantastic tool. Unbelievable job and I would love to use it. The only problem is that I really need to animate between the points in a linear fashion without the Catmull-Rom splines. So I ended up using iTween, but breaking down each path into X number of animations.

If there is a way to use this without the CatmullRom spline please let me know.

Really cool stuff man.

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

No one has followed this question yet.

Related Questions

Hashtable and ArrayList problem 0 Answers

Can I make a list of hashtables or classes with pragma strict 2 Answers

Most efficient way to store a list of data as a string? 1 Answer

How to check execution order from script? 0 Answers

Accessing quadrant/joystick number when using multiple xbox 360 controllers 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