// Use this for initialization public override void Start() { enable = true; FlyTime = 0f; Vx = MyGameObject.GetComponent <DiskData>().speed; Direction = MyGameObject.GetComponent <DiskData>().direction; }
//Controls the instatiation process of creating the particle private void CreateGravityObject() { //Creates references for the ParticlePrefabs and ParticleSprites CreateGravityPlanetReferences(); //Only one prefab for Gravity GameObject planetObject = Instantiate(ParticlePrefabs[0]) as GameObject; //Centered on the screen planetObject.transform.position = new Vector3(0, 1, 0); MyGameObject = planetObject; //Gets random number System.Random generator = new System.Random(); int index = generator.Next(0, ParticleSprites.Length - 1); //Random sprite is seected from the list MyGameObject.GetComponent <SpriteRenderer>().sprite = ParticleSprites[index] as Sprite; //Default value diameter = 0.25f; //Assigns particles index value to the attached script //This is used when performing collision calculations MyGameObject.GetComponent <newCollisionsController>().particleIndex = ParticleInstances.Count; }
protected virtual void OnTrackingFound() { //Display Canvas Children GameObject MainCanvas = GameObject.Find("Canvas"); foreach (Transform child in MainCanvas.transform) { if (child.gameObject.name == "MoveObjectButtons") { child.gameObject.SetActive(true); } else { child.gameObject.SetActive(true); } } //Hide the ImageTarget Status text ImageTargetStatusText.SetActive(false); if (mTrackableBehaviour) { if (PlayerPrefs.HasKey("NumberOfObjects")) { //TODO: ReDo int NumberOfObjects = PlayerPrefs.GetInt("NumberOfObjects"); GameObject MyGameObject; for (int counter = 1; counter <= NumberOfObjects; counter++) { if (GameObject.Find(counter.ToString()) == null) { //Check if the key exists if (PlayerPrefs.HasKey(counter.ToString())) { //Create a dictionary Dictionary <string, float> dict_ = new Dictionary <string, float>(); //Hold the string version of the counter string counterString_ = counter.ToString(); //Hold the "key" name of the string, which is equal to the counter in every iteration string stringHolder = PlayerPrefs.GetString(counterString_); //Convert the string content to the dictionary dict_ = ConvertStringToDict(stringHolder); //instantiate prefab instance int TypeToCreate = (int)dict_["Type"]; MyGameObject = Instantiate(ARObjectsArray[TypeToCreate]); //Assign its name MyGameObject.name = counterString_; //Assign its type DistinctiveObjectData distinctiveObjectData = MyGameObject.GetComponent <DistinctiveObjectData>(); distinctiveObjectData.type = TypeToCreate; //set the image target as parent of prefab instance //MyGameObject.transform.parent = this.transform; //Set the local location values of the instance using the information being held in the dictionaries MyGameObject.transform.localPosition = new Vector3(dict_["PosX"], dict_["PosY"], dict_["PosZ"]); //set every prefab instance in layer 9 to make sure that they are the only collidable objects in the scene when raycasting MyGameObject.layer = 9; } } else//If the gameobject already exists { //Gameobject variable to access the gameobjects GameObject go; go = GameObject.Find(counter.ToString()); // Get the Dictionary of this Object Dictionary <string, float> ObjectDictionary = ConvertStringToDict(PlayerPrefs.GetString(counter.ToString())); //Compare current step and the object's step value if (ObjectDictionary["StepValue"] == GetCurrentStep()) { //Enable renderer and collider components of the object go.GetComponent <MeshRenderer>().enabled = true; go.GetComponent <Collider>().enabled = true; } else { //Disable renderer and collider components of the object go.GetComponent <MeshRenderer>().enabled = false; go.GetComponent <Collider>().enabled = false; } } } } else { Debug.Log("There is no object created click create object button to create an object"); } UpdateRenderedObjects(); } }