public void InitFigure() { try { DataManager.Load(); List <string> _assetNames = DataManager.PlayerData.AssetNames; int random = Random.Range(0, _assetNames.Count); assetBundleManager.LoadAssetBundle(_assetNames[random].ToLower()); GeometryObjectData geometryData = Resources.Load <GeometryObjectData>("Installers/GeometryObjectData"); GeometryObjectModel asset = assetBundleManager.FindMyAssetFromBundle(geometryData); if (asset != null) { Instantiate(asset); GameData gameData = Resources.Load <GameData>("Installers/GameData"); timer = new Timer(gameData.ObservableTime, asset.ChangeColor); print("Time to change color: " + gameData.ObservableTime); print("Min click count:" + asset.ClickData.MinClicksCount); print("Max click count:" + asset.ClickData.MaxClicksCount); timer.Restart(); } else { print("Asset doesn't exist in loaded bundle"); } } catch (System.NullReferenceException e) { print("First Save some bundles through Assets/BuildAssets"); } }
void Start() { string json = File.ReadAllText(Application.dataPath + "/Scenes/Resources/ListObjectType.txt"); //загружаем названия фигур jsonName = JsonUtility.FromJson <NameFigure>(json); geometryObjectData = Resources.Load("Prefab/GeometryObjectData") as GeometryObjectData; //загружаем условия смены цвета }
private void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit mouseHit; if (Physics.Raycast(ray, out mouseHit)) { if (mouseHit.transform.gameObject.layer != 8) { return; } Collider[] hitColliders = Physics.OverlapSphere(mouseHit.point + offset, 0.5f); if (hitColliders.Length > 1) { return; } GameObject spawnObject = GetRandomFigure(); GeometryObjectData tempData = spawnObject.GetComponent <GeometryObjectModel>().Data; GameObject instance = Instantiate(spawnObject, mouseHit.point + offset, Quaternion.identity); instance.GetComponent <GeometryObjectModel>().Init(tempData); } } }
// Use this for initialization void Start() { StartCoroutine(LoadAssetBundles()); //load Asset Bundles from server geometryObjectDataManager = Resources.Load <GeometryObjectData>("ScriptableObject"); //load GeometryObjectData from Recources data = ResourcesLoader.LoadResourceTextFile("Data"); //load GameDataJson that contain PrefabNames array allPrefbNames = data.PrefabNames; gameArea.OnClick += GameArea_OnClick; }
private void LoadData() { GeometryObjectData data_figure = Resources.Load <GeometryObjectData>("Figures/GeometryObjectData_" + type.ToString()); cicksData = data_figure.ClicksData; GameData data_game = Resources.Load <GameData>("GameData"); observableTime = data_game.ObservableTime; }
private void Awake() { Resources.LoadAsync <GameData>("Data/ClicksColorDatas/GameData") .AsAsyncOperationObservable() .Subscribe(x => GameData = x.asset as GameData) .AddTo(this); Resources.LoadAsync <GeometryObjectData>("Data/ClicksColorDatas/GeometryObjectData") .AsAsyncOperationObservable() .Subscribe(x => GeometryObjectData = x.asset as GeometryObjectData) .AddTo(this); }
void Awake() { if (Instance == null) { DontDestroyOnLoad(gameObject); Instance = this; } else if (Instance != this) { Destroy(gameObject); } PlayerInput = GetComponent <InputManager>(); Data = Resources.Load <GameData>("ScriptableObjects/Game Data"); GeometryData = Resources.Load <GeometryObjectData>("ScriptableObjects/Geometry Data"); }
public GeometryObjectModel FindMyAssetFromBundle(GeometryObjectData objectData) { var assets = myLoadedAssetBundle.LoadAllAssets(); foreach (GameObject asset in assets) { for (int index = 0; index < objectData.ClicksData.Count; index++) { if (asset.name == objectData.ClicksData[index].ObjectType) { GeometryObjectModel myObject = asset.GetComponent <GeometryObjectModel>(); myObject.ClickData = objectData.ClicksData[index]; return(myObject); } ; } } myLoadedAssetBundle.Unload(true); return(null); }
IEnumerator AsynLoadData() { yield return(Resources.LoadAsync <GeometryObjectData>("ScriptObjects/GeometryObjectData").AsAsyncOperationObservable() .Subscribe(xs => { geometryObjectData = xs.asset as GeometryObjectData; })); }
void Start() { _objRenderer = GetComponent <Renderer>(); _geometryObjectData = Resources.Load <GeometryObjectData>(gameObject.name.Substring(0, gameObject.name.IndexOf('(')) + "Data"); ClickCount = 0; }