uuid 生成公式 批量生成新的uuid uuid 批量替换 php 小工具

感谢 panda 的 js 算法

<?php set_time_limit(0); ini_set('memory_limit','512M'); define('mulu' , str_replace('\\',"/",dirname(__FILE__)).'/'); function p(){ $args=func_get_args(); if(count($args)<1){ echo ("必须为p()函数提供参数!"); return; } echo '
';

   foreach($args as $arg){
       if(is_array($arg)){  
             print_r($arg);
             echo '
'; }else if(is_string($arg)){ echo $arg.'
'; }else{ var_dump($arg); echo '
'; } } echo '
'; } //远程获取 function qfopen($HTTP_Servr,$kai=1){ $handle = fopen ($HTTP_Servr, "rb"); //$_SERVER["QUERY_STRING"] ?后网址必须http:// $contents = ""; do { $data = fread($handle, 10240); if (strlen($data) == 0) { break; } $contents .= $data; } while(true); fclose ($handle); return $contents; } $_POST['uuid'] = array(); $_POST['uuid2'] = array(); $_POST['max'] = 0; $_POST['num'] = 0; function mululiu($dir,$virtual = false){ $ds = '/'; $dir = $virtual ? realpath( $dir ) : $dir; $dir = substr( $dir, -1 ) == $ds ? substr( $dir, 0, -1) : $dir; if (is_dir( $dir ) && $handle = opendir( $dir )){ while ( $file = readdir( $handle )){ if ( $file == '.' || $file == '..') continue; elseif ( is_dir( $dir . $ds . $file)) mululiu( $dir . $ds . $file); else{ $_POST['max']++; $yuanlu = $dir . $ds . $file; if( strpos( $file , ".meta") !== false ){ $shuzi = qfopen($yuanlu); preg_match_all('#uid": "(.*)",#',$shuzi,$url_arr); if($url_arr['1']){ foreach($url_arr['1'] as $ddd){ $_POST['uuid'][] = $ddd; } } } } } closedir( $handle ); return true; } } function mululiu2($dir,$virtual = false){ $ds = '/'; $dir = $virtual ? realpath( $dir ) : $dir; $dir = substr( $dir, -1 ) == $ds ? substr( $dir, 0, -1) : $dir; if (is_dir( $dir ) && $handle = opendir( $dir )){ while ( $file = readdir( $handle )){ if ( $file == '.' || $file == '..') continue; elseif ( is_dir( $dir . $ds . $file)) mululiu2( $dir . $ds . $file); else{ $_POST['num']++; shell_exec("`clear`"); echo "uuid替换进度 ".( sprintf("%.3f",($_POST['num']/$_POST['max']*100)) )." %\r\n"; $yuanlu = $dir . $ds . $file; $shuju = qfopen($yuanlu); if( strpos( $shuju , "uid") !== false ){ $shuju = str_replace($_POST['uuid'],$_POST['uuid2'],$shuju); file_put_contents( $yuanlu , $shuju ); } } } closedir( $handle ); return true; } } function typeid($zifu){ $zifu =str_replace("-","",$zifu); $qianwu = substr($zifu,0,5); $ase64KeyChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; $length = strlen($zifu); $i = 5; $zi = ""; while ($i < $length) { $hexVal1 = hexdec($zifu[$i]); $hexVal2 = hexdec($zifu[$i + 1]); $hexVal3 = hexdec($zifu[$i + 2]); $zi .=$ase64KeyChars[($hexVal1 <> 2)]; $zi .=$ase64KeyChars[(($hexVal2 & 3) << 4) | $hexVal3]; $i += 3; } return $qianwu.$zi; } mululiu(mulu); /*不能大于五位*/ $QIANZIU = "a11"; $QIANZIUlen = strlen($QIANZIU); foreach($_POST['uuid'] as $dfd){ $_POST['uuid2'][] =$QIANZIU.substr($dfd,$QIANZIUlen,strlen($dfd)); } foreach($_POST['uuid'] as $dfd){ $_POST['uuid'][] = typeid($dfd); $_POST['uuid2'][] = typeid($QIANZIU.substr($dfd,$QIANZIUlen,strlen($dfd))); } mululiu2(mulu); php 版本 uuid 批量替换 命名 支持5位替换 uuid 生成 _type_ js的 核心算法 $zifu =str_replace("-","",$zifu); $qianwu = substr($zifu,0,5); $ase64KeyChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; $length = strlen($zifu); $i = 5; $zi = ""; while ($i < $length) { $hexVal1 = hexdec($zifu[$i]); $hexVal2 = hexdec($zifu[$i + 1]); $hexVal3 = hexdec($zifu[$i + 2]); $zi .=$ase64KeyChars[($hexVal1 <> 2)]; $zi .=$ase64KeyChars[(($hexVal2 & 3) << 4) | $hexVal3]; $i += 3; } return $qianwu.$zi; uuid.php.zip (1.6 KB) uuid 批量替换 php 小工具
1赞

请问,如何通过prefab里的__type__找到对应的uuid文件吗?这个__type__是base64编码之后的,那能直接通过__type__解码获取到对应的uuid吗?很急用,感谢!

你可以 更改下 代码 先找出 uuid 然后 生成 uuid 的 type 超着 对应_type_ 对应的uuid 即可

你也可以 逆向算法
$hexVal1 = hexdec($zifu[$i]);
$hexVal2 = hexdec($zifu[$i + 1]);
$hexVal3 = hexdec($zifu[$i + 2]);
$zi .=$ase64KeyChars[($hexVal1 << 2) | ($hexVal2 >> 2)];
$zi .=$ase64KeyChars[(($hexVal2 & 3) << 4) | $hexVal3];

逆向回去

这个工具是做什么的?感觉做成 Creator 插件会更简单点,不用自己实现这些算法

批量替换uuid :sweat_smile::sweat_smile::sweat_smile::sweat_smile::sweat_smile:
防止子游戏 重复uuid

先马,回头用到了再研究

大神,膜拜……

我想问一下楼主 panda的JS算法在哪个帖子能否提供下链接?

用楼主的脚本批量更换了uuid以后,再重新打开项目,节点上挂的脚本都丢失了,请问该如何处理?

怎么批量修改uuid并且不会出现场景资源丢失

场景上的uuid要一起修改吧