Exemplo n.º 1
0
    private void UpdateToolPresentation()
    {
        // Create a temp module
        string     toolPrefabFile = CNetwork.Factory.GetRegisteredPrefabFile(CToolInterface.GetPrefabType(m_CurrentToolType.Get()));
        GameObject toolObject     = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/" + toolPrefabFile));

        // Destroy the old module
        if (m_ParentToolObject.transform.childCount != 0)
        {
            Destroy(m_ParentToolObject.transform.GetChild(0).gameObject);
        }

        // Update the tool info
        UpdateToolInfo(toolObject.GetComponent <CToolInterface>());

        // Destroy the non rendering
        CUtility.DestroyAllNonRenderingComponents(toolObject);

        // Add it to the child object
        toolObject.transform.parent = m_ParentToolObject.transform;

        // Reset some values
        CUtility.SetLayerRecursively(toolObject, LayerMask.NameToLayer("UI 3D"));
        toolObject.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
        toolObject.transform.localRotation = Quaternion.identity;

        // Set the scale a lot smaller
        toolObject.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
    }