Esempio n. 1
0
    // Use this for initialization. Only called once per script
    void Start()
    {
        displayAreaAnimator = GameObject.Find("DisplayArea").GetComponent <Animator>();

        mainViewManager = GameObject.Find("DisplayArea/MainView").GetComponent <MainViewManager>();
        // Get ref to database
        database = GameObject.Find("Database").GetComponent <Database>();
        // get ref to guiUpdate
        // guiUpdateSkript = GameObject.Find("GUI_Update").GetComponent<guiUpdate>();

        // Get transform of the 3d model of the module.
        // Marker game object only has one child, thus this works!
        foreach (Transform moduleModel in gameObject.transform)
        {
            moduleTransform = moduleModel;
        }

        // Get transform and make button for every process object
        moduleProcessObjects = new List <Transform>();
        moduleButtons        = new List <Canvas>();

        // Get all children that are present in the 3D model and extract empties. These are the relevant process objects.
        // Empties are located in the second hierarchy leve under the module game object!
        Transform[] moduleChildren = moduleTransform.gameObject.GetComponentsInChildren <Transform>();
        foreach (Transform moduleProcessObject in moduleChildren)
        {
            // Look all direct children of the 3D modell (should be empties).
            // If we have found something that is NOT the direct child of the 3D model: continue
            if (moduleProcessObject.parent.transform != moduleTransform)
            {
                continue;
            }
            // Exclude the ground
            if (moduleProcessObject.name == "ground")
            {
                continue;
            }

            // If we get here: we have a direct child of the 3D modell: save and make button
            // Save transform
            moduleProcessObjects.Add(moduleProcessObject);
            // Make button, give it a name, get the canvas and save
            GameObject newButton = Instantiate(ButtonPrefab, moduleTransform.parent.transform, false);
            newButton.transform.name = moduleProcessObject.name;
            //newButton.name = "M001";
            newButton.transform.localScale            = new Vector3(10, 10, 10);
            newButton.GetComponent <Canvas>().enabled = false;
            //newButton.GetComponentInChildren<Button>().onClick.AddListener(() => { displayAreaAnimator.SetTrigger("EnterDetailView"); });
            moduleButtons.Add(newButton.GetComponent <Canvas>());
        }
        // We now have everything that we need: the module transform, a list of all process objects in the model and a list of all buttons for those process objects.
    }
Esempio n. 2
0
 void Awake()
 {
     Instance = this;
     //StartCoroutine (cacheWindow ());
     cacheWindowFinish(null);
 }