This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:

Sidebar

en:vci:sample:onuse:no5

A poster that changes texture when used


This data works with “Virtual Cast 1.5.1a and later”.

Example data:https://seed.online/items/6a93ae195893107e661eb9aed7782f77b92c32e70b44ab6c0f18095169e74e08

You can switch the texture by pressing the grip button.

As shown in the image below, prepare a 3-by-3 texture and use
vci.assets._ALL_SetMaterialTextureOffsetFromIndex to shift the UV offset.

The same change can be done using vci.assets._ALL_SetMaterialTextureOffsetFromName which specifies a Material by its name.
The material in the example can be specified by the name “board_5tai7”.

The UV of the picture side of the poster is set to a cell of the 3-by-3 matrix grid.
(To set the UV, use 3D modeling software like blender and Maya)

main.lua
local assets = vci.assets
local count = 0
if vci.state.Get("COUNT") then
    count = vci.state.Get("COUNT")
end
local TOTAL = 6
 
function SetTextureOffset( count )
    local offset = Vector2.zero
 
    -- y shift
    local Yshift = math.floor(count / 3)
    offset.y = -(1/3) * Yshift
 
    -- x shift
    local Xshift = count % 3
    offset.x = (1/3) * Xshift
 
    assets._ALL_SetMaterialTextureOffsetFromIndex(0, offset)
end
SetTextureOffset(count)
 
function onUse(use)
    if count >= TOTAL-1 then
        count = 0
    else
        count = count + 1
    end
    vci.state.Set("COUNT", count)
    SetTextureOffset(count)
end
en/vci/sample/onuse/no5.txt · Last modified: 2019/07/09 18:24 by h-eguchi

Page Tools