コード例 #1
0
    //nel LateUpdate correggo le posizioni ed eventuali derive degli oggetti specificati
    void LateUpdate()
    {
        //se un evento di un bottone è stato consumato, lo resetto
        resetButtons();

        if (loadSaveState == LoadSaveState.Save)
        {
            if ((Mathf.Abs(Time.time - lastCorrectionTime)) > correctionTime)
            {
                lastCorrectionTime = Time.time;
                for (int i = 0; i < gameObjectsToControl.Count; i++)
                {
                    if (gameObjectsToControl[i] != null && gameObjectsToControl[i].tag != "")
                    {
                        GameObjectToControl tempGOTC = new GameObjectToControl();

                        GameObject tempGO = GameObject.FindGameObjectWithTag(gameObjectsToControl[i].tag);

                        tempGOTC.tag = gameObjectsToControl[i].tag;
                        //tempGOTC.gameObject = gameObjectsToControl[i].gameObject;
                        Vector3 tempPos = tempGO.transform.position;
                        tempGOTC.position = new Vect3(tempPos.x, tempPos.y, tempPos.z);
                        Vector3 tempScale = tempGO.transform.localScale;
                        tempGOTC.scale = new Vect3(tempScale.x, tempScale.y, tempScale.z);
                        Quaternion tempQuaternion = tempGO.transform.rotation;
                        tempGOTC.rotation = new Quat(tempQuaternion.x, tempQuaternion.y, tempQuaternion.z, tempQuaternion.w);

                        ChangedObjects tempChanged = new ChangedObjects(Time.time, tempGOTC);
                        changedObjectsList.Add(tempChanged);
                    }
                }
            }
        }

        //List<string> stringList = new List<string>();
        if (loadSaveState == LoadSaveState.Load && adjustPositions)
        {
            for (int i = 0; i < changedObjectsList.Count; i++)
            {
                if (changedObjectsList [i] != null && changedObjectsList[i].gameObjectToControl.tag != "")
                {
                    //se ho passato il tempo
                    if (changedObjectsList [i].changingTime < Time.time)
                    {
                        GameObject tempGO = GameObject.FindGameObjectWithTag(changedObjectsList[i].gameObjectToControl.tag);

                        Vect3 tempPos   = changedObjectsList[i].gameObjectToControl.position;
                        Vect3 tempScale = changedObjectsList[i].gameObjectToControl.scale;
                        Quat  tempRot   = changedObjectsList[i].gameObjectToControl.rotation;

                        tempGO.transform.position   = new Vector3(tempPos.x, tempPos.y, tempPos.z);
                        tempGO.transform.localScale = new Vector3(tempScale.x, tempScale.y, tempScale.z);
                        tempGO.transform.rotation   = new Quaternion(tempRot.x, tempRot.y, tempRot.z, tempRot.w);

                        changedObjectsList.RemoveAt(i);
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
    }
コード例 #2
0
 public ChangedObjects(float inputTime, GameObjectToControl inputGameObjectToControl)
 {
     this.changingTime        = inputTime;
     this.gameObjectToControl = inputGameObjectToControl;
 }