Beispiel #1
0
    public virtual void Load(Transform parent, Action <WearableController> onSuccess, Action <WearableController> onFail)
    {
        bonesRetargeted = false;

        var representation = wearable.GetRepresentation(bodyShapeType);
        var provider       = wearable.GetContentProvider(bodyShapeType);

        loader = new RendereableAssetLoadHelper(provider, wearable.baseUrlBundles);

        loader.settings.forceNewInstance     = true;
        loader.settings.initialLocalPosition = Vector3.up * 0.75f;
        loader.settings.cachingFlags         = MaterialCachingHelper.Mode.CACHE_SHADERS;
        loader.settings.visibleFlags         = AssetPromiseSettings_Rendering.VisibleFlags.INVISIBLE;
        loader.settings.parent = parent;

        loader.OnSuccessEvent += (x) =>
        {
            PrepareWearable(x);
            onSuccess.Invoke(this);
        };

        loader.OnFailEvent += () => onFail.Invoke(this);

        loader.Load(representation.mainFile);
    }
    public virtual void Load(string bodyShapeId, Transform parent, Action <WearableController> onSuccess, Action <WearableController> onFail)
    {
        if (isReady)
        {
            return;
        }

        boneRetargetingDirty = true;

        var representation = wearable.GetRepresentation(bodyShapeId);

        if (representation == null)
        {
            onFail?.Invoke(this);
            return;
        }

        var provider = wearable.GetContentProvider(bodyShapeId);

        loader = new RendereableAssetLoadHelper(provider, wearable.baseUrlBundles);

        loader.settings.forceNewInstance     = false;
        loader.settings.initialLocalPosition = Vector3.up * 0.75f;
        loader.settings.cachingFlags         = MaterialCachingHelper.Mode.CACHE_SHADERS;
        loader.settings.visibleFlags         = AssetPromiseSettings_Rendering.VisibleFlags.INVISIBLE;
        loader.settings.parent = parent;

        assetRenderers = null;

        void OnSuccessWrapper(GameObject gameObject)
        {
            if (loader != null)
            {
                loader.OnSuccessEvent -= OnSuccessWrapper;
            }
            assetRenderers = gameObject.GetComponentsInChildren <Renderer>();
            PrepareWearable(gameObject);
            onSuccess?.Invoke(this);
        }

        loader.OnSuccessEvent += OnSuccessWrapper;

        void OnFailEventWrapper()
        {
            if (loader != null)
            {
                loader.OnFailEvent -= OnFailEventWrapper;
                loader.ClearEvents();
                lastMainFileLoaded = null;
                loader             = null;
            }
            onFail?.Invoke(this);
        }

        loader.OnFailEvent += OnFailEventWrapper;

        lastMainFileLoaded = representation.mainFile;
        loader.Load(representation.mainFile);
    }