コード例 #1
0
    public void DeleteModelFromTerrain(GameObject gameObject)
    {
        var toDelete = ModelsOnTerrain.First(x => x.GameObject == gameObject);

        GameObject.Destroy(toDelete.GameObject);
        ModelsOnTerrain.Remove(toDelete);
    }
コード例 #2
0
    public void DeleteModel(Guid modelGuid)
    {
        var objToDelete = ModelsOnTerrain.Where(x => x.ModelGuid == modelGuid).ToList();

        foreach (var obj in objToDelete)
        {
            GameObject.Destroy(obj.GameObject);
            ModelsOnTerrain.Remove(obj);
        }

        GameObject.Destroy(Models[modelGuid].GameObject);
        Models.Remove(modelGuid);
    }
コード例 #3
0
    public void UpdateModelsOnTerrain(Guid modelGuid)
    {
        var toUpdate = ModelsOnTerrain.Where(x => x.ModelGuid == modelGuid).ToList();

        foreach (var model in toUpdate)
        {
            var updatedObj = InstantiateModel(modelGuid);
            updatedObj.transform.position   = model.GameObject.transform.position;
            updatedObj.transform.rotation   = model.GameObject.transform.rotation;
            updatedObj.transform.localScale = model.GameObject.transform.localScale;

            GameObject.Destroy(model.GameObject);
            model.GameObject = updatedObj;
        }
    }
コード例 #4
0
    public McSceneData GetData()
    {
        var data = new McSceneData();

        data.Guid        = Guid;
        data.TerrainGuid = Terrain.Data.Guid;
        data.Models      = ModelsOnTerrain.Select(x => new McSceneModelData()
        {
            Guid     = x.ModelGuid,
            Position = x.GameObject.transform.localPosition,
            Rotation = x.GameObject.transform.localRotation.eulerAngles,
            Scale    = x.GameObject.transform.localScale,
        }).ToList();

        return(data);
    }
コード例 #5
0
    public GameObject InstantiateModel(Guid guid)
    {
        var obj = GameObject.Instantiate(Models[guid].GameObject);

        obj.name                    = McConsts.ObjectPrefix + guid.ToString();
        obj.transform.parent        = this.transform;
        obj.transform.localScale    = new Vector3(0.2f, 0.2f, 0.2f);
        obj.transform.localPosition = Vector3.zero;
        ModelsOnTerrain.Add(new McObject(guid, obj));

        obj.AddComponent <ObjectController>();
        obj.AddComponent <MovementWithOculusTouch>();
        obj.GetComponent <MovementWithOculusTouch>().enabled = false;
        obj.AddComponent <FullRotationWithOculusTouch>();
        obj.GetComponent <FullRotationWithOculusTouch>().enabled = false;
        obj.AddComponent <ScaleWithOculusTouch>();
        obj.GetComponent <ScaleWithOculusTouch>().enabled = false;

        obj.SetActive(true);

        return(obj);
    }