// Update is called once per frame void Update() { if (TransitionTimer > 0.0f) { TransitionTimer -= Time.deltaTime; if (Current != null) { Current.opacity = 1.0f - TransitionTimer / MaxTransitionTimer; } if (Previous != null) { Previous.opacity = TransitionTimer / MaxTransitionTimer; } } else { Previous = null; /*foreach(SpatioModel r in list){ * if(r != Current) * r.gameObject.SetActive(false); * else * r.gameObject.SetActive(true); * }*/ } }
public void SwitchTo(int year) { Year = year; SpatioModel closest = null; foreach (SpatioModel r in list) { if (!r.hidden && r.start.Year <= year && r.end.Year >= year) { r.gameObject.SetActive(true); } else { r.gameObject.SetActive(false); } /*if (r.start.Year <= year && (closest == null || r.start.Year - closest.start.Year >= 0)) * { * closest = r; * }*/ } /*slider.value = year; * if (closest != Current) * { * Previous = Current; * Current = closest; * * TransitionTimer = MaxTransitionTimer; * if(Previous) * Previous.gameObject.SetActive(true); * if(Current) * Current.gameObject.SetActive(true); * * SetInfoText(); * } * SetDateText(); */ }
// Use this for initialization void Start() { bool minSet = false, maxSet = false; list = GetComponentsInChildren <SpatioModel> (true); Current = list [0]; Current.opacity = 1.0f; foreach (SpatioModel ro in list) { if (!maxSet || ro.start.Year > (int)slider.maxValue) { maxSet = true; //Avoids the risk of weird slider crash if (ro.start.Year < (int)slider.minValue) { minSet = true; slider.minValue = ro.start.Year; start = ro.start; } slider.maxValue = ro.start.Year; end = ro.end; } if (!minSet || ro.start.Year < (int)slider.minValue) { minSet = true; start = ro.start; slider.minValue = ro.start.Year; } } Year = Current.start.Year; SetDateText(); SetInfoText(); slider.onValueChanged.AddListener(delegate { YearChangeCheck(); }); }
void OnWizardCreate() { GameObject model; GameObject go = Instantiate(Resources.Load("SpatioSet")) as GameObject; SpatioSet rs = go.GetComponent <SpatioSet>(); string[] files = Directory.GetFiles(folderField); if (files != null && files.Length > 0) { foreach (string filename in files) { //Check to see if it's an fbx file if (!filename.EndsWith(".fbx")) { continue; } //Construct the full file path string filepath = folderField; filepath = filename; //Create a new SpatioModel and begin loading and setting up the components model = new GameObject(); string model_year = "tst"; SpatioModel sm = model.AddComponent <SpatioModel>(); //Add a SpatioModel component MeshFilter meshFilter = model.AddComponent <MeshFilter>(); //Add a MeshFilter Component MeshRenderer meshRenderer = model.AddComponent <MeshRenderer>(); //Add a MeshRenderer Component //Material mat = new Material(Shader.Find("Legacy/Transparent/Specular")); //Create a Material //AssetDatabase.CreateAsset(mat, "Assets/Materials/" + mat.name + ".mat"); //Make the Material into an asset //meshRenderer.material = mat; //Assign the Material to the meshRenderer meshFilter.mesh = AssetDatabase.LoadAssetAtPath(filepath, typeof(Mesh)) as Mesh; //Load the mesh from the fbx file //GameObject pf = PrefabUtility.CreatePrefab("Assets/SpatioModels/" + nameField + "/" + model_year + ".prefab", model); model.transform.parent = go.transform; } } go.name = nameField; }
void ParseSpatioModel(GameObject go, string data) { SpatioModel sm = null; string[] dataset; Debug.Log("Parsing: " + data); string[] properties = data.Split('\n'); foreach (string p in properties) { Debug.Log("Property: " + p); if (p.StartsWith("RESTOMODEL")) { sm = go.AddComponent <SpatioModel> (); Collider collider = go.AddComponent <MeshCollider> (); } else if (p.StartsWith("START")) { if (sm == null) { Debug.Log("rm not found!"); continue; } dataset = p.Split(' '); sm.start = new Date(); sm.start.Month = int.Parse(dataset [dataset.Length - 1].Substring(0, 2)); sm.start.Day = int.Parse(dataset [dataset.Length - 1].Substring(2, 2)); sm.start.Year = int.Parse(dataset [dataset.Length - 1].Substring(4, 4)); Debug.Log("Start Date: " + sm.start.ToString()); } else if (p.StartsWith("END")) { if (sm == null) { Debug.Log("rm not found!"); continue; } dataset = p.Split(' '); sm.end = new Date(); sm.end.Month = int.Parse(dataset [dataset.Length - 1].Substring(0, 2)); sm.end.Day = int.Parse(dataset [dataset.Length - 1].Substring(2, 2)); sm.end.Year = int.Parse(dataset [dataset.Length - 1].Substring(4, 4)); Debug.Log("End Date: " + sm.end.ToString()); } else if (p.StartsWith("NAME")) { if (sm == null) { Debug.Log("rm not found!"); continue; } sm.name = p.Substring(7); Debug.Log("Name: " + sm.name); } else if (p.StartsWith("DESCRIPTION")) { if (sm == null) { Debug.Log("rm not found!"); continue; } sm.Description = p.Substring(13); Debug.Log("Description: " + sm.Description); } else if (p.StartsWith("TAG")) { string t; t = p.Substring(6); sm.tags = new List <string>(t.Split(',')); Debug.Log("Tags: " + sm.tags.ToString()); } else if (p.StartsWith("BLOCK")) { sm.block = p.Substring(8); Debug.Log("Block: '" + sm.block + "'"); } else if (p == null) { Debug.Log("Null Field"); } else { Debug.Log("First Value: " + p [0]); } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.LeftControl)) { if (Instructions.active == false) { Instructions.SetActive(true); } else if (Instructions.active == true) { Instructions.SetActive(false); } //Hide both UI tabs? //show Instructions Panel } if (Input.GetKeyDown(KeyCode.RightControl)) { if (informationPanel.active == false) { informationPanel.SetActive(true); } else if (informationPanel.active == true) { informationPanel.SetActive(false); } } //for highlighting objects and using their block value to cull the documents if (Input.GetKeyDown("a")) { //Debug.Log("a key was pressed"); //send a ray from the camera to the current mouse cursor RaycastHit hit; //need to run this command from the proper camera, aerial or FPS CheckActiveCamera(); Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { Transform objectHit = hit.transform; //set material to outline AddHighlight(objectHit.gameObject); if (highlightObject == hit.collider.gameObject) { //then wait for a click to actually change the panel //Debug.Log(objectHit.ToString()); try { SpatioModel temp = objectHit.GetComponent <SpatioModel>(); string BlockNumber = temp.block.ToString(); string StartDate = temp.start.Year.ToString(); string EndDate = temp.end.Year.ToString(); informationPanel.GetComponentInChildren <Text>().text = "Block " + BlockNumber + "\r\n" + StartDate + " " + EndDate; //Debug.Log(BlockNumber); DocumentsPanel.GetComponent <SpatioDocuments>().ToggleButtonDisplay(BlockNumber); } catch { } } return; } //query the result //send the result to the block documents } //o is keyed to camera movement, that script is on the main scene camera if (Input.GetKeyDown("o")) { //print("o key was pressed"); //orbit mode } }