Skip to content

Commit

Permalink
- Fix a mtl replace string problem
Browse files Browse the repository at this point in the history
- Fix naming in prefabs poi it and decoration
- Allow also ogv file upload
- Fix a bug in no img for asset screenshot
  • Loading branch information
jimver04 committed Dec 18, 2017
1 parent f2744d5 commit fb72164
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 17 deletions.
3 changes: 2 additions & 1 deletion WordpressUnity3DEditor-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ function my_myme_types($mime_types){
$mime_types['json'] = 'text/json';
$mime_types['obj'] = 'text/plain';
$mime_types['mp4'] = 'video/mp4';
$mime_types['ogv'] = 'video/ogv';
$mime_types['ogv'] = 'application/ogg';
$mime_types['ogg'] = 'application/ogg';
$mime_types['mtl'] = 'text/plain';
$mime_types['mat'] = 'text/plain';
$mime_types['pdb'] = 'text/plain';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,11 @@ function wpunity_addAssets_wonderaround_unity($scene_id){
$decor_scale_x = $value['scale'][0];
$decor_scale_y = $value['scale'][1];
$decor_scale_z = $value['scale'][2];
$decor_title = get_the_title($decoarch_id);

$decoarch_finalyaml = wpunity_replace_decoration_arch_unity($decorarch_yaml,$decor_fid,$decor_obj_guid,$decor_pos_x,$decor_pos_y,$decor_pos_z,$decor_rot_x,$decor_rot_y,$decor_rot_z,$decor_rot_w,$decor_scale_x,$decor_scale_y,$decor_scale_z);
$decoarch_finalyaml = wpunity_replace_decoration_arch_unity($decorarch_yaml,$decor_fid,$decor_obj_guid,$decor_pos_x,$decor_pos_y,
$decor_pos_z,$decor_rot_x,$decor_rot_y,$decor_rot_z,$decor_rot_w,$decor_scale_x,$decor_scale_y,$decor_scale_z,
$decor_title);
$allObjectsYAML = $allObjectsYAML . $LF . $decoarch_finalyaml;
}

Expand Down Expand Up @@ -402,7 +405,9 @@ function wpunity_replace_wonderaround_unity($term_meta_wonder_around, $scene_id)
return $file_content_return;
}

function wpunity_replace_decoration_arch_unity($decorarch_yaml,$decor_fid,$decor_obj_guid,$decor_pos_x,$decor_pos_y,$decor_pos_z,$decor_rot_x,$decor_rot_y,$decor_rot_z,$decor_rot_w,$decor_scale_x,$decor_scale_y,$decor_scale_z){
function wpunity_replace_decoration_arch_unity($decorarch_yaml,$decor_fid,$decor_obj_guid,$decor_pos_x,$decor_pos_y,
$decor_pos_z,$decor_rot_x,$decor_rot_y,$decor_rot_z,$decor_rot_w,
$decor_scale_x,$decor_scale_y,$decor_scale_z,$decor_title){

$file_content_return = str_replace("___[decor_fid]___",$decor_fid,$decorarch_yaml);
$file_content_return = str_replace("___[decor_obj_guid]___",$decor_obj_guid,$file_content_return);
Expand All @@ -416,6 +421,7 @@ function wpunity_replace_decoration_arch_unity($decorarch_yaml,$decor_fid,$decor
$file_content_return = str_replace("___[decor_scale_x]___",$decor_scale_x,$file_content_return);
$file_content_return = str_replace("___[decor_scale_y]___",$decor_scale_y,$file_content_return);
$file_content_return = str_replace("___[decor_scale_z]___",$decor_scale_z,$file_content_return);
$file_content_return = str_replace("___[decor_title]___",$decor_title,$file_content_return);

return $file_content_return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ___[poi_v_obj_guid]___, type: 3}
m_IsPrefabParent: 0
');
');

$ini_asset_site = array('--- !u!1001 &___[site_fid]___
Prefab:
Expand Down Expand Up @@ -157,7 +157,7 @@
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ___[site_obj_guid]___, type: 3}
m_IsPrefabParent: 0
');
');

$ini_asset_poi = array("--- !u!1001 &___[poi_it_fid]___
Prefab:
Expand Down Expand Up @@ -210,7 +210,7 @@
propertyPath: m_RootOrder
value: 7
objectReference: {fileID: 0}
- target: {fileID: 4761904222008530, guid: 4c118634f374a3647acbe1862739fb17, type: 2}
- target: {fileID: 1075652707080240, guid: 4c118634f374a3647acbe1862739fb17, type: 2}
propertyPath: m_Name
value: ___[poi_it_title]___
objectReference: {fileID: 0}
Expand Down Expand Up @@ -250,7 +250,7 @@
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ___[poi_it_obj_guid]___, type: 3}
m_IsPrefabParent: 0
");
");

$ini_asset_door = array('--- !u!1001 &___[door_fid]___
Prefab:
Expand Down Expand Up @@ -340,7 +340,7 @@
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ___[door_guid]___, type: 3}
m_IsPrefabParent: 0
');
');

$ini_asset_artifact = array('--- !u!1001 &___[poi_a_fid]___
Prefab:
Expand Down Expand Up @@ -425,7 +425,7 @@
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ___[poi_a_obj_guid]___, type: 3}
m_IsPrefabParent: 0
');
');

$ini_asset_decoration_arch = array('--- !u!1001 &___[decor_fid]___
Prefab:
Expand Down Expand Up @@ -474,10 +474,14 @@
propertyPath: m_LocalScale.z
value: ___[decor_scale_z]___
objectReference: {fileID: 0}
- target: {fileID: 100000, guid: ___[decor_obj_guid]___, type: 3}
propertyPath: m_Name
value: ___[decor_title]___
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: ___[decor_obj_guid]___, type: 3}
m_IsPrefabParent: 0
');
');

function wpunity_default_value_poi_video_get(){
global $ini_asset_poi_video;
Expand Down
12 changes: 7 additions & 5 deletions includes/templates/edit-wpunity_asset3D-saveData.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ function wpunity_create_asset_poisVideoExtra_frontend($asset_newID){
$asset_featured_imageForm = $_FILES['poi-video-featured-image'];
$asset_videoForm = $_FILES['videoFileInput'];




$attachment_id = wpunity_upload_img_vid( $asset_featured_imageForm, $asset_newID);
set_post_thumbnail( $asset_newID, $attachment_id );

Expand Down Expand Up @@ -188,10 +191,8 @@ function wpunity_create_asset_3DFilesExtra_frontend($asset_newID, $assetTitleFor
for($i=0; $i < count($tContent); $i++) {

$textureFile_id = wpunity_upload_Assetimg64(
$tContent[$textureNamesIn[$i]],
'texture_'.$textureNamesIn[$i].'_'.$assetTitleForm,
$asset_newID,
$gameSlug);
$tContent[$textureNamesIn[$i]], 'texture_'.$textureNamesIn[$i].'_'.$assetTitleForm,
$asset_newID, $gameSlug);

$textureFile_filename = basename(get_attached_file($textureFile_id));

Expand All @@ -205,7 +206,8 @@ function wpunity_create_asset_3DFilesExtra_frontend($asset_newID, $assetTitleFor
for ($k = 0; $k < count($textureNamesIn); $k++) {
// $mtl_content = str_replace("map_Kd ".$textureNamesIn[$k].".jpg", "map_Kd ".$textureNamesOut[$k], $mtl_content);
// This replace is better. It does not depend on the number of white spaces.
$mtl_content = preg_replace("/.*\b" . 'map_Kd' . "\b.*/ui", "map_Kd " . $textureNamesOut[$k], $mtl_content);
$mtl_content = preg_replace("/.*\bmap_Kd\b.*\b".$textureNamesIn[$k].".jpg\b/ui",
"map_Kd " . $textureNamesOut[$k], $mtl_content);
}

$mtlFile_id = wpunity_upload_AssetText($mtl_content, 'material'.$assetTitleForm, $asset_newID, $gameSlug);
Expand Down
8 changes: 7 additions & 1 deletion includes/templates/edit-wpunity_asset3D.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php



function loadAsset3DManagerScripts() {
// Three js : for simple rendering
wp_enqueue_script('wpunity_scripts');
Expand Down Expand Up @@ -185,6 +187,8 @@ function loadAsset3DManagerScripts() {
$asset_desc_saved = ($create_new == 1 ? "" : get_post_field('post_content', $asset_checked_id));
$asset_desc_label = ($create_new == 1 ? "Add a small description for your asset" : "Edit the description of your asset");

//print_r(get_allowed_mime_types());

//Check if its new/saved and get data for Terrain Options
if($create_new == 0) {
$saved_term = wp_get_post_terms( $asset_checked_id, 'wpunity_asset3d_cat' );
Expand Down Expand Up @@ -395,9 +399,11 @@ function loadAsset3DManagerScripts() {

<h3 class="mdc-typography--title">Video POI Details</h3>



<div id="videoFileInputContainer" class="mdc-layout-grid__cell mdc-layout-grid__cell--span-6">
<label for="videoFileInput"> Select a video</label>
<input class="FullWidth" type="file" name="videoFileInput" value="" id="videoFileInput" accept="video/mp4,video/ogv"/>
<input class="FullWidth" type="file" name="videoFileInput" value="" id="videoFileInput" accept="video/*"/>
</div>
</div>

Expand Down
4 changes: 3 additions & 1 deletion js_libs/scriptFileBrowserToolbarWPway.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ function file_Browsing_By_DB(responseData, gameProjectSlug, urlforAssetEdit) {
}

if (!f.screenImagePath) {
f.screenImagePath = f.mtlPath.substr(0, f.mtlPath.indexOf('uploads')) + 'plugins/WordpressUnity3DEditor/images/ic_no_sshot.png';
f.screenImagePath = window.location.origin + "/wp-content/plugins/wordpressunity3deditor/images/ic_no_sshot.png";
//f.mtlPath.substr(0, f.mtlPath.indexOf('uploads')) +
//'plugins/WordpressUnity3DEditor/images/ic_no_sshot.png';
}

img = '<span class="mdc-list-item__start-detail CenterContents"><img draggable="false" src=' + f.screenImagePath +'><br><span class="mdc-typography--caption mdc-theme--text-secondary-on-light">'+ fileSize +'</span></span>';
Expand Down

0 comments on commit fb72164

Please sign in to comment.