• Hi Guest!

    We are extremely excited to announce the release of our first Beta1.1 and the first release of our Public AddonKit!
    To participate in the Beta, a subscription to the Entertainer or Creator Tier is required. For access to the Public AddonKit you must be a Creator tier member. Once subscribed, download instructions can be found here.

    Click here for information and guides regarding the VaM2 beta. Join our Discord server for more announcements and community discussion about VaM2.
  • Hi Guest!

    VaM2 Resource Categories have now been added to the Hub! For information on posting VaM2 resources and details about VaM2 related changes to our Community Forums, please see our official announcement here.

VaM 1.x any way to scale multiple assets?

Threads regarding the original VaM 1.x

Mm3

Member
Joined
Apr 12, 2022
Messages
80
Reactions
7
any way to scale multiple assets?
i have tons of assets in my scene and i want to scale them to be bigger but it would be a nightmare to do them one by one
 
If you assign all the assets to one parent atom and add the colorscale plugin to it, the parented assets will scale with it. The issue it that the objects positions scale relative to the object too, so unless you are scaling the whole environment, they will move away from where you have them placed.

 
Upvote 0
Please, search the forums before posting, there's a thread for Editing CUA answered a day ago.

 
Upvote 0
If you assign all the assets to one parent atom and add the colorscale plugin to it, the parented assets will scale with it. The issue it that the objects positions scale relative to the object too, so unless you are scaling the whole environment, they will move away from where you have them placed.

i tried it and it does work but only at the present scene
one saved and reloaded everything gets reset to original size my scene got all messed up😞
 
Upvote 0
Please, search the forums before posting, there's a thread for Editing CUA answered a day ago.

thank you but its not what i need, i need a way to scale multiple assets at ones.
this plugin while is very useful only changes one asset at a time unless i'm missing something?
 
Upvote 0
The documentation says
- change All scale(X,Y,Z)

But I'm not generally doing that so I might be wrong :p
 
Upvote 0
i tried it and it does work but only at the present scene
one saved and reloaded everything gets reset to original size my scene got all messed up😞
Sorry about that. It's something I noticed this plugin does by accident when I scaled a parent atom. I did test a scene with a few different asset types before I posted and it reloaded the save fine for me. I didn't restart Vam, so maybe it's a session thing? You may have to do it the hard way.
 
Upvote 0
I'm realizing that in reality you're asking to scale multiple CustomUnityAssets, but MULTIPLE ATOMS, right?
 
Upvote 0
Sorry about that. It's something I noticed this plugin does by accident when I scaled a parent atom. I did test a scene with a few different asset types before I posted and it reloaded the save fine for me. I didn't restart Vam, so maybe it's a session thing? You may have to do it the hard way.
i was hoping to avoid that😞 thanks anyway
 
Upvote 0
I'm realizing that in reality you're asking to scale multiple CustomUnityAssets, but MULTIPLE ATOMS, right?
yes sorry if i didn't explain it right, color scale plugin that Origin69 suggested really does what i want but after scene load every atom gets reset to original scale.
 
Upvote 0
yes sorry if i didn't explain it right, color scale plugin that Origin69 suggested really does what i want but after scene load every atom gets reset to original scale.

Are you trying to push the asset sizes like crazy nuts or is a somewhat standard 0.5/2/3 times scale?
 
Upvote 0
And with the normal scale slider in the CUA, what would be the size you're aiming for?
 
Upvote 0
And with the normal scale slider in the CUA, what would be the size you're aiming for?
3 or 4, i'm trying to make a scene with size differences but since scaling person atom lower than 0.300 causes issues i thought to scale up the other person.
i have too many assets in my scene so that's why scaling one by one will take all my free time that i barely have 😞
 
Upvote 0
Ok.
I'll make you a quick plugin that will update the CUA scale on the fly for all CUA present in the scene. I'll keep you posted.
 
Upvote 0
Here you go, just copy the code below in a text file. Rename the text file and change its extension to something like "multi_cua_rescaler.cs", put it in your Scripts folder and load it as a session plugin.



C#:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR;
using UnityEngine.Events;
using System;
using System.Collections;
using System.Collections.Generic;
using SimpleJSON;
using System.Linq;
using System.IO;

// MultiCUARescaler v1.0 - hazmhox
//
// Allows you to rescale all CUAs at once

namespace MultiCUARescalerPlugin
{
    public class MultiCUARescaler : MVRScript
    {
        // Statics
        private static string PLUGIN_NAME = "Multi CUA Rescaler";

        protected List<JSONStorableFloat> allCuaSliders = new List<JSONStorableFloat>();
        protected List<UIDynamicSlider> allCuaSlidersUI = new List<UIDynamicSlider>();
        
        protected bool _isSceneLoading { get { return SuperController.singleton.isLoading; } }
        public bool isSceneFrozen { get { return SuperController.singleton.freezeAnimation; } }
        public bool isInEditMode { get { return SuperController.singleton.gameMode == SuperController.GameMode.Edit; } }
        
        public override void Init()
        {             
            try
            {
                if (containingAtom.type != "SessionPluginManager")
                {
                    SuperController.singleton.Alert("<b><color=green>"+PLUGIN_NAME+"</color></b>\nSession plugin.\nPlease add it in your session plugins.", () => {});
                    return;
                }

                CreateStaticDescriptionText("Title","<color=#000><size=35><b>" + PLUGIN_NAME + "</b>\nThe plugin can rescale all CUA, it's a session plugin and does not save data. It will simply update the CUA scale in the scene</size></color>",true,250,TextAnchor.MiddleLeft);
                
                OnSceneLoaded();
            }
            catch(Exception e)
            {
                logError(PLUGIN_NAME + " - Exception caught: " + e);
            }
        }
        
        void Start()
        {

        }

        void ClearUI()
        {
            foreach (UIDynamicSlider uids in allCuaSlidersUI)
            {
                RemoveSlider(uids);
            }

            allCuaSlidersUI.Clear();
            allCuaSliders.Clear();
        }

        private void OnEnable()
        {
            SuperController.singleton.onSceneLoadedHandlers += OnSceneLoaded;
        }
        
        private void OnDisable()
        {
            SuperController.singleton.onSceneLoadedHandlers -= OnSceneLoaded;
        }
        
        // **************************
        // Callbacks
        // **************************

        private void OnSceneLoaded()
        {
            ClearUI();
            
            UIDynamicSlider tmpSlider;
            foreach (Atom at in SuperController.singleton.GetAtoms())
            {
                if (at.type == "CustomUnityAsset")
                {
                    JSONStorable scaleVal = at.GetStorableByID("scale");
                    JSONStorableFloat cuaSizeElem = new JSONStorableFloat(at.name + "_resize", scaleVal.GetFloatParamValue("scale"), 0f, 10f){isStorable=false,isRestorable=false};
                    cuaSizeElem.setCallbackFunction += (val) => { OnChangeCUASize(at, val); };
                    tmpSlider = CreateSlider(cuaSizeElem, false);
                    tmpSlider.valueFormat = "F2";
                    tmpSlider.label = at.name + " Scale";

                    allCuaSliders.Add(cuaSizeElem);
                    allCuaSlidersUI.Add(tmpSlider);
                }
            }
            
            JSONStorableFloat cuaSizeAll = new JSONStorableFloat("all_resize", 1f, 0f, 10f){isStorable=false,isRestorable=false};
            cuaSizeAll.setCallbackFunction += (val) => { OnChangeCUAAllSizes(val); };
            tmpSlider = CreateSlider(cuaSizeAll, true);
            tmpSlider.valueFormat = "F2";
            tmpSlider.label = "Change all CUA Scale";
            allCuaSlidersUI.Add(tmpSlider);
        }

        private void OnChangeCUASize(Atom at, float val)
        {
            at.GetStorableByID("scale").SetFloatParamValue("scale", val);
        }
        
        private void OnChangeCUAAllSizes(float value)
        {
            foreach (JSONStorableFloat jsf in allCuaSliders)
            {
                jsf.val = value;
            }
        }

        // **************************
        // Time to cleanup !
        // **************************
        void OnDestroy() {

        }
        
        // **************************
        // Local Tools
        // **************************
        private void logDebug( string debugText ) {
            SuperController.LogMessage( debugText );
        }
        
        private void logError( string debugText ) {
            SuperController.LogError( debugText );
        }
        
        public UIDynamicTextField CreateStaticDescriptionText(string DescTitle, string DescText, bool rightSide, int fieldHeight, TextAnchor textAlignment = TextAnchor.UpperLeft, bool disableBackground = true, bool disableScroll = true ) {
            JSONStorableString staticDescString = new JSONStorableString(DescTitle,DescText) {isStorable=false,isRestorable=false};
            staticDescString.hidden = true;
            UIDynamicTextField staticDescStringField = CreateTextField(staticDescString, rightSide);
            if( disableBackground ) staticDescStringField.backgroundColor = new Color(1f, 1f, 1f, 0f);
            staticDescStringField.UItext.alignment = textAlignment;
            LayoutElement sdsfLayout = staticDescStringField.GetComponent<LayoutElement>();
            sdsfLayout.preferredHeight = sdsfLayout.minHeight = fieldHeight;
            staticDescStringField.height = fieldHeight;
            if( disableScroll ) DisableScrollOnText(staticDescStringField);
            return staticDescStringField;
        }
        
        public static void DisableScrollOnText(UIDynamicTextField target) {
            // THIS is important, it's a "useless" temporary canvas group that will prevent the event from the mousewheel
            CanvasGroup tmpCG = target.UItext.transform.parent.transform.parent.transform.parent.gameObject.AddComponent<CanvasGroup>();
            tmpCG.blocksRaycasts = false;
            
            ScrollRect targetSR = target.UItext.transform.parent.transform.parent.transform.parent.GetComponent<ScrollRect>();
            if( targetSR != null ) {
                targetSR.horizontal = false;
                targetSR.vertical = false;
            }
        }
    }
}
 
Upvote 0
Back
Top Bottom