Exemplo n.º 1
0
        private static void SendMessage <T>(string messageName, T e) where T : Message
        {
            TimerManager.Instance.StartCoroutine(DealMessage <T>(messageName, e));

            ATrace.Log("Send Message:" + typeof(T).ToString());
            //UnityEngine.Debug.Log("Send Message:" + typeof(T).ToString());
        }
Exemplo n.º 2
0
        public virtual void SendMsg <T>(ESET_Result r) where T : State_Base_Msg
        {
            ATrace.Log("State_Base_Msg:" + typeof(T).ToString() + " : " + r);

            _Result = r;
            Message.Send <T>((T)this);
        }
Exemplo n.º 3
0
    protected void SetOneMaterial(Material mat, int index, int sum, Rect rc, PanoManager.EPANOTEXTUREMODE texMode, PanoManager.PanoTextureForOneDevice texDevice)
    {
        ATrace.Log(string.Format("SetOneMaterial: index:{0} sum:{1} rc:{2}", index, sum, rc.ToString()));
        PanoManager.PanoTextureForOneDevice dv = texDevice;

        if (texMode == PanoManager.EPANOTEXTUREMODE.EPM_YUV)
        {
            if (dv._TextureArr.Length > 0)
            {
                SetOneMaterialOneParam(mat, index, sum, rc, dv._TextureArr[0], "_MainTex");
            }
            if (dv._TextureArr.Length > 1)
            {
                SetOneMaterialOneParam(mat, index, sum, rc, dv._TextureArr[1], "_MainTexU");
            }
            if (dv._TextureArr.Length > 2)
            {
                SetOneMaterialOneParam(mat, index, sum, rc, dv._TextureArr[2], "_MainTexV");
            }
        }
        else if (texMode == PanoManager.EPANOTEXTUREMODE.EMP_RGB)
        {
            if (dv._TextureArr.Length > 0)
            {
                SetOneMaterialOneParam(mat, index, sum, rc, dv._TextureArr[0]);
            }
        }
        else if (texMode == PanoManager.EPANOTEXTUREMODE.EPM_SurfaceToTexture)
        {
            if (dv._TextureArr.Length > 0)
            {
                SetOneMaterialOneParam(mat, index, sum, rc, dv._TextureArr[0]);
            }
        }
    }
Exemplo n.º 4
0
    public UnityEngine.Object GetAsset()
    {
#if UNITY_EDITOR
        if (AssetBundleLoadManager.SimulateAssetBundleInEditor)
        {
            string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(m_AssetBundleName, m_AssetName);
            if (assetPaths.Length == 0)
            {
                ATrace.LogError("There is no asset with name \"" + m_AssetName + "\" in " + m_AssetBundleName);
                return(null);
            }

            // @TODO: Now we only get the main object from the first asset. Should consider type also.
            UnityEngine.Object target = AssetDatabase.LoadMainAssetAtPath(assetPaths[0]);
            return(target);
        }
#endif

        LoadedAssetBundle bundle = AssetBundleLoadManager.Instance.GetLoadedAssetBundle(m_AssetBundleName, out m_DownloadingError);
        if (bundle == null)
        {
            ATrace.Log("GetAsset fail:" + m_AssetBundleName);
            return(null);
        }
        if (m_Request != null && m_Request.isDone)
        {
            ATrace.Log("GetAsset succ:" + m_AssetBundleName);
            return(m_Request.asset);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 5
0
        public virtual void SendMsg <T>(bool b) where T : Bool_Base_Msg
        {
            ATrace.Log("Bool_Base_Msg:" + typeof(T).ToString() + " : " + b);

            _b = b;
            Message.Send <T>((T)this);
        }
Exemplo n.º 6
0
    public override void SetMaterial(PanoManager.EPANOTEXTUREMODE texMode, Vector2 mediaSize, Vector2 contentSize, params PanoManager.PanoTextureForOneDevice[] texDeviceArr)
    {
        ATrace.Log(string.Format("Pano11Mesh SetOneMaterial: texMode:{0} mediaSize:{1} contentSize:{2}", texMode, mediaSize, contentSize
                                 ));
        int i = 0;


        ATrace.Log("Pano11Mesh texDeviceArr.Length:" + texDeviceArr.Length);
        foreach (Renderer r in _Renderers)
        {
            Material mat = new Material(PanoManager.Instance.GetShader(texMode));
            r.material = mat;

            if (texDeviceArr.Length > i)//应当传入两个设备的图集
            {
                r.gameObject.SetActive(true);
                //两个镜头的两张贴图,所以TexArr取不同index
                SetOneMaterial(mat, 0, 1, GetContentRect(mediaSize, contentSize), texMode, texDeviceArr[i]);
            }
            else
            {
                r.gameObject.SetActive(false);
            }

            i++;
        }

        base.SetMaterial(texMode, mediaSize, contentSize, texDeviceArr);
    }
Exemplo n.º 7
0
    public void Log()
    {
        foreach (Renderer r in _Renderers)
        {
            Material mat = r.sharedMaterial;

            ATrace.Log(string.Format("Current Mat:{0} Shader: {0}", mat, ToString(), mat.shader.ToString()));
        }
    }
Exemplo n.º 8
0
    byte[] readFromFile(string File_Name)
    {
        ATrace.Log("XmlFile:" + File_Name);
        TextAsset textContent = Resources.Load(File_Name) as TextAsset;

        if (textContent == null)
        {
            return(null);
        }
        return(textContent.bytes);
    }
Exemplo n.º 9
0
 protected void SetOneMaterialOneParam(Material mat, int index, int sum, Rect rc, Texture tex = null, string texname = "_MainTex")
 {
     ATrace.Log("SetOneMaterialOneParam:" + mat);
     if (mat && mat.HasProperty(texname))
     {
         ATrace.Log("SetOneMaterialOneParam Texture Scale Offset:" + mat + " index:" + index + "sum:" + sum);
         mat.SetTexture(texname, tex);
         mat.SetTextureScale(texname, GetTexScale(index, sum, rc));
         mat.SetTextureOffset(texname, GetTexOffset(index, sum, rc));
     }
 }
Exemplo n.º 10
0
    public void SetPanoMode(EPANOMODE showMode = EPANOMODE.OLD, EPANOTEXTUREMODE texmode = EPANOTEXTUREMODE.EMP_OLD, params PanoTextureForOneDevice[] texDeviceArr)
    {
        if (texDeviceArr.Length > 0)
        {
            mPanoTextureDeviceArr = texDeviceArr;
        }

        if (showMode != EPANOMODE.OLD)
        {
            _CurShowMode = showMode;
        }
        if (texmode != EPANOTEXTUREMODE.EMP_OLD)
        {
            _CurrentTextureMode = texmode;
        }


        ATrace.Log(string.Format("SetPanoMode: {0} : {1}", _CurShowMode, _CurrentTextureMode));

        foreach (KeyValuePair <EPANOMODE, PanoMeshBase> kv in mPanoMeshDic)
        {
            if (_CurShowMode == kv.Key)
            {
                kv.Value.gameObject.SetActive(true);
                if (mPanoTextureDeviceArr != null)
                {
                    kv.Value.SetMaterial(_CurrentTextureMode, mMediaSize, mContentSize, mPanoTextureDeviceArr);
                }
            }
            else
            {
                kv.Value.gameObject.SetActive(false);
            }
        }

        if (mPanoTextureDeviceArr != null && mPanoTextureDeviceArr.Length > 0)
        {
            PanoTextureForOneDevice dv = mPanoTextureDeviceArr[0];
            if (dv != null && dv._TextureArr.Length > 0)
            {
                Texture tex = dv._TextureArr[0];

                int width  = (int)(tex.width * mContentSize.x / mMediaSize.x);
                int height = (int)(tex.height * mContentSize.y / mMediaSize.y);

                SetPreRenderTextureSizeByShowMode(_CurShowMode, width, height);
            }
        }

        PanoTextureResetMsg msg = new PanoTextureResetMsg();

        PanoTextureResetMsg.Send <PanoTextureResetMsg>(msg);
    }
Exemplo n.º 11
0
    private void UnloadAssetBundleInternal(string assetBundleName, bool unloadAllLoadedObjects)
    {
        string            error;
        LoadedAssetBundle bundle = GetLoadedAssetBundle(assetBundleName, out error);

        if (bundle == null)
        {
            return;
        }


        ATrace.Log("Unload:" + assetBundleName);
        bundle.m_AssetBundle.Unload(unloadAllLoadedObjects);
        m_LoadedAssetBundles.Remove(assetBundleName);
    }
Exemplo n.º 12
0
    public override void DoCallback()
    {
        bool isdone = IsDone();

        if (isdone)
        {
            if (m_LoadedCallback != null)
            {
                m_LoadedCallback(null, null);
            }
        }
        else
        {
            ATrace.LogError(string.Format("Asset: {0} - {1} Load Operation not done while do callback", m_AssetBundleName, m_AssetName));
        }
    }
Exemplo n.º 13
0
    private IEnumerator Initialize()
    {
#if UNITY_EDITOR
        // If we're in Editor simulation mode, we don't need the manifest assetBundle.
        if (SimulateAssetBundleInEditor)
        {
            yield break;
        }
#endif

        string bundleName = AssetBundlePlatformPathManager.GetPlatformAssetbundlePath();
        string assetName  = "AssetBundleManifest";
        WWW    download   = null;
        string url        = "";
        if (m_ManifestFromHttp == true)
        {
            url = AssetBundlePlatformPathManager.GetDownloadingHttpAssetBundleURL() + bundleName;
        }
        else
        {
            url = AssetBundlePlatformPathManager.GetAssetBundleDownloadingURL_StreamingAsset() + bundleName;
        }
        ATrace.Log("AssetBundle Manifest :" + url);


        download = new WWW(url);
        while (download.isDone != true)
        {
            yield return(0);
        }
        if (download.error != null)
        {
            ATrace.LogError(string.Format("AssetBundle Manifest load Error:{0}", download.error));
        }
        else
        {
            m_AssetBundleManifest = download.assetBundle.LoadAsset <AssetBundleManifest>(assetName);
            if (m_AssetBundleManifest == null)
            {
                ATrace.LogError(string.Format("AssetBundle Manifest load Failed"));
            }
            else
            {
            }
        }
    }
Exemplo n.º 14
0
    void InitDic(XmlDocument xmldoc)
    {
        try
        {
            XmlNode node = xmldoc.ChildNodes.Item(0);

            int index = 0;

            foreach (XmlNode nodeChild in node.ChildNodes)
            {
                Dictionary <string, string> vals = new Dictionary <string, string>();


                string mainkey = index.ToString();

                bool valid = false;

                foreach (XmlAttribute valChild in nodeChild.Attributes)
                {
                    string key   = valChild.Name;
                    string value = valChild.Value;
                    vals[key] = value;

                    if (!string.IsNullOrEmpty(value))
                    {
                        valid = true;
                    }
                }

                if (valid)
                {
                    xmlTable.Add(mainkey, vals);
                }
                index++;
            }
        }
        catch (Exception e)
        {
            ATrace.LogError("Load Xml Failed : " + xmldoc.BaseURI);
        }
    }
Exemplo n.º 15
0
    public override void SetMaterial(PanoManager.EPANOTEXTUREMODE texMode, Vector2 mediaSize, Vector2 contentSize, params PanoManager.PanoTextureForOneDevice[] texDeviceArr)
    {
        int i = 0;

        foreach (Renderer r in _Renderers)
        {
            Material mat = new Material(PanoManager.Instance.GetShader(texMode));

            r.material = mat;

            if (texDeviceArr != null && texDeviceArr.Length > 0)//默认设备只有一个,只取[0]
            {
                SetOneMaterial(mat, i, 2, GetContentRect(mediaSize, contentSize), texMode, texDeviceArr[0]);
                ATrace.Log(string.Format("SetMaterial:{0} {1}", i, r.gameObject.name));
            }


            i++;
        }

        base.SetMaterial(texMode, mediaSize, contentSize, texDeviceArr);
    }
Exemplo n.º 16
0
    public LoadedAssetBundle GetLoadedAssetBundle(string assetBundleName, out string error)
    {
        if (m_DownloadingErrors.TryGetValue(assetBundleName, out error))
        {
            ATrace.LogError(string.Format("LoadedAssetBundel DownloadingErrors :{0}", error));
            return(null);
        }
        LoadedAssetBundle bundle = null;

        m_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle);
        if (bundle == null)
        {
            //ATrace.LogError(string.Format("LoadedAssetBundle :{0} not Found", assetBundleName));
            return(null);
        }
        // No dependencies are recorded, only the bundle itself is required.
        string[] dependencies = null;
        if (!m_Dependencies.TryGetValue(assetBundleName, out dependencies))
        {
            ATrace.Log("GetLoadedAssetBundle no dependency" + assetBundleName);
            return(bundle);
        }
        // Make sure all dependencies are loaded
        foreach (var dependency in dependencies)
        {
            // Wait all the dependent assetBundles being loaded.
            LoadedAssetBundle dependentBundle;
            m_LoadedAssetBundles.TryGetValue(dependency, out dependentBundle);
            if (dependentBundle == null)
            {
                //ATrace.LogError(string.Format("LoadedAssetBundel Dependency :{0} not Found", dependency));
                return(null);
            }
        }

        ATrace.Log("GetLoadedAssetBundle with dependency" + assetBundleName);
        return(bundle);
    }
Exemplo n.º 17
0
    // Load AssetBundle and its dependencies.
    public void StartLoadAssetBundle(string assetBundleName, bool fromHttp)
    {
        if (!Working)
        {
            ATrace.LogError("AssetBundleLoadManager not Working");
            StartCoroutine(WaitWorking(assetBundleName, fromHttp));
            return;
        }

        if (m_DownloadingWWWs.ContainsKey(assetBundleName))
        {
            ATrace.Log(string.Format("AssetBundleLoadManager already process AssetBundle:{0}", assetBundleName));
            return;
        }
        if (m_LoadedAssetBundles.ContainsKey(assetBundleName))
        {
            ATrace.Log(string.Format("AssetBundleLoadManager already loaded AssetBundle:{0}", assetBundleName));
            return;
        }

#if UNITY_EDITOR
        // If we're in Editor simulation mode, we don't have to really load the assetBundle and its dependencies.
        if (SimulateAssetBundleInEditor)
        {
            return;
        }
#endif
        // Check if the assetBundle has already been processed.
        bool isAlreadyProcessed = LoadAssetBundleInternal(assetBundleName, fromHttp);

        // Load dependencies.
        if (!isAlreadyProcessed)
        {
            LoadDependencies(assetBundleName, fromHttp);
        }
    }
Exemplo n.º 18
0
 public virtual void SendMsg <T>() where T : Simple_Msg
 {
     ATrace.Log("Simple_Msg:" + typeof(T).ToString());
     Message.Send <T>((T)this);
 }