Beispiel #1
0
        private static void OnLoadSuccess(DecalParam arg1, UnityObject arg2)
        {
            _logger.DebugFormat("Decal-Combined OnLoadSuccess !");
            if (arg2 == null || arg2.AsObject == null)
            {
                _logger.DebugFormat("arg2 == null || arg2.AsObject == null  !");
                return;
            }

            _debugGameObject = arg2.AsObject as GameObject;
            arg1.entity.assets.LoadedAssets.Add(arg1.assetInfo, arg2);
            Decal decal = _debugGameObject.AddComponent <Decal>();

            _debugGameObject.transform.localScale = new Vector3(1.2f, 4.0f, 1.2f);
            _debugGameObject.transform.position   = arg1.position;
            //_debugGameObject.transform.right = arg1.head;
            //_debugGameObject.transform.up = -arg1.forward;
            AngleTrans(ref arg1.head, _debugGameObject.transform);

            if (arg1.contexts == null)
            {
                return;
            }

            var bundleName = AssetBundleConstant.Icon_Spray;
            var assetName  = string.Format("Spray_{0}", arg1.sprayPrintSpriteId);

            _logger.DebugFormat(assetName);
            var assetManager = arg1.contexts.session.commonSession.AssetManager;

            assetManager.LoadAssetAsync(assetName, new AssetInfo(bundleName, assetName), (source, unityObj) =>
            {
                if (unityObj != null && unityObj.AsObject != null)
                {
                    Texture2D texture = unityObj.AsObject as Texture2D;
                    if (texture != null)
                    {
                        assetManager.LoadAssetAsync(texture, new AssetInfo("shaders", "New Material"), OnMaterialLoadSus);
                    }
                    else
                    {
                        _logger.DebugFormat("LoadAssetAsync failed !");
                        GameObject.Destroy(_debugGameObject);
                    }
                }
                else
                {
                    _logger.DebugFormat("bundleName : " + bundleName + " assetName : " + assetName);
                }
            });
        }
Beispiel #2
0
        public static void CreateBasicDecal(ClientEffectEntity entity,
                                            Contexts contexts,
                                            Vector3 position,
                                            Vector3 forward,
                                            Vector3 head,
                                            int sprayPrintSpriteId)
        {
            CreateDebugGameObject();
            var assetManager = contexts.session.commonSession.AssetManager;

            string     bundleNameSpray = AssetBundleConstant.Prefab_Spray;
            DecalParam decalParam      = new DecalParam();
            AssetInfo  assetInfo       = new AssetInfo(bundleNameSpray, "Decal-Combined");

            decalParam.entity             = entity;
            decalParam.contexts           = contexts;
            decalParam.position           = position;
            decalParam.forward            = forward;
            decalParam.head               = head;
            decalParam.sprayPrintSpriteId = sprayPrintSpriteId;
            decalParam.assetInfo          = assetInfo;
            _logger.DebugFormat("CreateBasicDecal");
            assetManager.LoadAssetAsync(decalParam, assetInfo, OnLoadSuccess);
        }
Beispiel #3
0
        private static void OnLoadSuccess(DecalParam arg1, UnityObject arg2)
        {
            _logger.DebugFormat("Decal-Combined OnLoadSuccess !");
            if (arg2 == null || arg2.AsObject == null)
            {
                _logger.DebugFormat("arg2 == null || arg2.AsObject == null  !");
                return;
            }

            _debugGameObject = arg2.AsObject as GameObject;
            arg1.entity.assets.LoadedAssets.Add(arg1.assetInfo, arg2);
            Decal decal = _debugGameObject.AddComponent <Decal>();

            _debugGameObject.transform.localEulerAngles = Vector3.zero;
            Vector3 forward          = arg1.forward;
            float   multiplyingpower = forward.y / Math.Max(Math.Max(forward.x, forward.z), 0.01f);
            bool    ground           = (multiplyingpower > 0.577f);

            arg1.head.x = FreeMathUtility.yRoundx(forward);
            if (ground)
            {
                decal.transform.position = arg1.position;
            }
            else
            {
                arg1.head.y = 0;
                arg1.head.z = FreeMathUtility.yRoundz(forward);
                decal.transform.position = arg1.position - forward * 0.3f;
            }
            _debugGameObject.transform.localScale = new Vector3(0.75f, ground ? 0.06f : 0.64f, 0.75f);
            decal.transform.Rotate(arg1.head, Space.World);
            float result = Vector3.Dot(forward, decal.transform.forward);

            if (Math.Abs(result) > 0.1f)
            {
                Vector3 localEulerAngles = decal.transform.localEulerAngles;
                localEulerAngles.x = -localEulerAngles.x;
                localEulerAngles.z = -localEulerAngles.z;
                decal.transform.localEulerAngles = localEulerAngles;
            }

            if (arg1.contexts == null)
            {
                return;
            }
            var bundleName = AssetBundleConstant.Icon_Spray;
            var assetName  = string.Format("Spray_{0}", arg1.sprayPrintSpriteId);

            _logger.DebugFormat(assetName);
            var assetManager = arg1.contexts.session.commonSession.AssetManager;

            assetManager.LoadAssetAsync(assetName, new AssetInfo(bundleName, assetName), (source, unityObj) =>
            {
                if (unityObj != null && unityObj.AsObject != null)
                {
                    if (unityObj.AsObject is Texture2D)
                    {
                        Texture2D texture = unityObj.AsObject as Texture2D;
                        assetManager.LoadAssetAsync(texture, new AssetInfo("shaders", "New Material"), OnMaterialLoadSus);
                    }
                    else if (unityObj.AsObject is Sprite)
                    {
                        Sprite sprite = unityObj.AsObject as Sprite;
#if UNITY_EDITOR
                        Material m     = new Material(Shader.Find("Decalicious/Deferred Spray"));
                        decal.Material = m;
                        m.mainTexture  = sprite.texture;
                        _debugGameObject.GetComponent <MeshRenderer>().enabled = true;
#else
                        assetManager.LoadAssetAsync(sprite.texture, new AssetInfo("shaders", "New Material"), OnMaterialLoadSus);
#endif
                    }
                    else
                    {
                        _logger.DebugFormat("LoadAssetAsync failed !");
                        GameObject.Destroy(_debugGameObject);
                    }
                }
                else
                {
                    _logger.DebugFormat("bundleName : " + bundleName + " assetName : " + assetName);
                }
            });
        }