예제 #1
0
    private void UpdateModulePresentation()
    {
        // Create a temp module
        string     modulePrefabFile = CNetwork.Factory.GetRegisteredPrefabFile(CModuleInterface.GetPrefabType(m_CurrentModuleType.Get()));
        GameObject moduleObject     = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/" + modulePrefabFile));

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

        // Update the info
        UpdateModuleInfo(moduleObject.GetComponent <CModuleInterface>());

        // Destroy all non rendering components
        CUtility.DestroyAllNonRenderingComponents(moduleObject);

        // Add it to the child object
        moduleObject.transform.parent = m_ParentModuleObject.transform;

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

        // Set the scale a lot smaller
        moduleObject.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
    }
예제 #2
0
    public GameObject CreateModule(CModuleInterface.EType _eType)
    {
        GameObject cModuleObject = null;

        if (!IsModuleAttached)
        {
            cModuleObject = CNetwork.Factory.CreateObject(CModuleInterface.GetPrefabType(_eType));
            cModuleObject.GetComponent <CNetworkView>().SetPosition(m_Positioner.transform.position);
            cModuleObject.GetComponent <CNetworkView>().SetEulerAngles(m_Positioner.transform.rotation.eulerAngles);
            cModuleObject.GetComponent <CNetworkView>().SetParent(GetComponent <CNetworkView>().ViewId);

            m_cAttachedModuleViewId.Set(cModuleObject.GetComponent <CNetworkView>().ViewId);
        }
        return(cModuleObject);
    }