Пример #1
0
    public GameObject AddCulling(GameObject obj, string name = "CullingParent")
    {
        if (null == obj)
        {
            return(null);
        }
        GameObject obj2 = new GameObject(name);

        if (null == obj.transform.parent)
        {
            obj2.transform.position = obj.transform.position;
            obj2.transform.rotation = obj.transform.rotation;
        }
        else
        {
            obj2.transform.parent        = obj.transform.parent;
            obj2.transform.localPosition = obj.transform.localPosition;
            obj2.transform.localRotation = obj.transform.localRotation;
        }
        obj.transform.parent = obj2.transform;
        ObjectCulling component = obj2.GetComponent <ObjectCulling>();

        if (null == component)
        {
            component = obj2.AddComponent <ObjectCulling>();
        }
        component.Init(obj);
        return(obj2);
    }
Пример #2
0
    public GameObject AddCulling(GameObject obj, string name = "CullingParent")
    {
        if (null == obj)
        {
            return(null);
        }
        GameObject gameObject = new GameObject(name);

        if (null == obj.transform.parent)
        {
            gameObject.transform.position = obj.transform.position;
            gameObject.transform.rotation = obj.transform.rotation;
        }
        else
        {
            gameObject.transform.parent        = obj.transform.parent;
            gameObject.transform.localPosition = obj.transform.localPosition;
            gameObject.transform.localRotation = obj.transform.localRotation;
        }
        obj.transform.parent = gameObject.transform;
        ObjectCulling objectCulling = gameObject.GetComponent <ObjectCulling>();

        if (null == objectCulling)
        {
            objectCulling = gameObject.AddComponent <ObjectCulling>();
        }
        objectCulling.Init(obj);
        return(gameObject);
    }