Note that ghusl is considered as necessary in certain cases: janabah (by intercourse, or if semen comes out), menses, child birth, death, conversion (according to some scholars) etc. (See also islamqa #93027)
While wudu' is necessary in other cases among them is if one pees or mady or wady comes out. For details refer to Which things break the wudu?.
Therefore if you are performing ghusl and peed (no matter if it was intentionally or not) or anything which invalidates wudu' happened to you. You have not invalidated your ghusl as only one of the things mentioned above require ghusl. So your ghusl is correct and valid, but the wudu' is not therefore to be able to pray one needs to perform a new wudu' only (see islamqa #49693 and also islamweb #135504).