コード例 #1
0
ファイル: UIManager.cs プロジェクト: unstephen/S1_FrameWork
    public void Clear(bool reconnectToServer = false)
    {
        for (int i = 0; i < uis.Length; ++i)
        {
            if (uis[i] != null)
            {
                if (!uis[i].dontDestoryOnLoad)
                {
                    Remove(uis[i]);
                }
                else
                {
                    if (!reconnectToServer)
                    {
                        uis[i].OnLoadLevelBegin();
                    }
                }
            }
        }

        ArrayList keys = new ArrayList(loading.Keys);

        foreach (var k in keys)
        {
            string       key   = k as string;
            CGameUIAsset asset = loading[key];
            if (asset != null && !asset.dontDestoryOnLoad)
            {
                CClientCommon.DestroyImmediate(ref asset);
            }

            loading.Remove(key);
        }
    }
コード例 #2
0
    //---------------------------------------------------------------------
    public static void Initialize(List <string> categoryList)
    {
        m_CategoryMap.Clear();
        for (int i = 0; i < categoryList.Count; ++i)
        {
            string category = categoryList[i];
            CreateObject(category);
        }

        GameObject UnknownObject = GameObject.Find("Unknowns");

        if (UnknownObject == null)
        {
            UnknownObject = new GameObject();
            //UnknownObject.AddComponent<ImmortalComponent>();
            UnityEngine.Object.DontDestroyOnLoad(UnknownObject);
            UnknownObject.name = "Unknowns";
        }

        m_UnknownParent = UnknownObject.transform;
        m_CategoryMap[m_UnknownParent.name] = m_UnknownParent;

        foreach (var category in m_CategoryMap)
        {
            Transform categoryTrans = category.Value;
            CClientCommon.NormalizeTransform(categoryTrans);
        }

        m_IsInitialize = true;
    }
コード例 #3
0
ファイル: UIManager.cs プロジェクト: unstephen/S1_FrameWork
    public void Remove(CGameUI ui)
    {
        if (!ui || ui.disposed)
        {
            return;
        }
        if (ui.index < 0)
        {
            return;
        }
        uis[ui.index] = null;
        ui.Close();
        names.Remove(ui.Name);
        index_pool.Free(ui.index);
        ui.index = -1;

        if (loading.ContainsKey(ui.Name))
        {
            CGameUIAsset asset = loading[ui.Name] as CGameUIAsset;
            CClientCommon.DestroyImmediate(ref asset);
            loading.Remove(ui.Name);
        }
        ui.Dispose();
        ui = null;
    }
コード例 #4
0
 protected void ApplyParticleScale(float scale)
 {
     if (this.gameObject == null)
     {
         return;
     }
     CClientCommon.ApplyParticleScale(this.gameObject.transform, scale);
 }
コード例 #5
0
 public virtual void Dispose()
 {
     if (disposed)
     {
         return;
     }
     disposed = true;
     CClientCommon.DestroyImmediate(this);
 }
コード例 #6
0
    protected override void OnUpdate()
    {
        base.OnUpdate();

        if (start_time + duration_time <= GameTimer.time && start_time != 0)
        {
            CClientCommon.DestroyImmediate(this);
            start_time = duration_time = 0;
        }
    }
コード例 #7
0
 public override void Initialize()
 {
     image = CClientCommon.AddComponent <CImage>(this.gameObject);
     this.CreateSprite(image, "newmainface", "xiaohongdian");
     image.raycastTarget       = false;
     m_rectTransform           = GetComponent <RectTransform>();
     m_rectTransform.pivot     = new Vector2(0.5f, 0.5f);
     m_rectTransform.anchorMin = Vector2.one;
     m_rectTransform.anchorMax = Vector2.one;
     image.SetNativeSize();
 }
コード例 #8
0
 public void SetUI(GameObject parent, Vector2 pos)
 {
     if (redPointUI == null)
     {
         GameObject gameObject2 = new GameObject(CString.Concat(parent.gameObject.name, "_redPoint"));
         CClientCommon.SetActiveOverload(gameObject2, true);
         gameObject2.transform.parent = parent.transform;
         redPointUI     = gameObject2.AddComponent <RedDotUI2>();
         redPointUI.Arg = new object[] { pos };
     }
     ShowDot();
 }
コード例 #9
0
 protected virtual void Update()
 {
     if (BindObject == null || BindObject.disposed)
     {
         return;
     }
     if (Time.frameCount % 3 != 0)
     {
         return;
     }
     isCameravisible = CClientCommon.isCameraWithinScreen(Camera.main.WorldToScreenPoint(BindObject.Transform.position));
 }
コード例 #10
0
        // 加载资源

        protected virtual void OnCreate(AssetBundle asset_bundle)
        {
            if (asset_bundle != null)
            {
                Object[] objs = asset_bundle.LoadAllAssets();
                if (objs != null && objs.Length > 0)
                {
                    this.asset = objs[0];
                }
                renders = CClientCommon.ReplaceShader(this.asset, string.Empty);
                IResourceFactory.Cookie cookie = factory.GetCookie(name);
                cookie.RecordMemory(UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(asset), asset is GameObject);
            }
        }
コード例 #11
0
    protected override void OnDestroy()
    {
        DestroyComponent();

        if (this.gameObject)
        {
            CClientCommon.DestroyImmediate(gameObject);
        }


        if (!Application.isEditor)
        {
            GC.SuppressFinalize(this);
        }
    }
コード例 #12
0
    //---------------------------------------------------------------------
    public static Transform GetObject(string categoryName)
    {
        if (!IsInitialize())
        {
            return(null);
        }

        // Find path or name
        if (m_CategoryMap.ContainsKey(categoryName))
        {
            return(m_CategoryMap[categoryName]);
        }

        // Not Path
        if (categoryName.Contains("/"))
        {
            CreateObject(categoryName);
            return(m_CategoryMap[categoryName]);
        }

        // Find any contains the name
        foreach (var category in m_CategoryMap)
        {
            if (category.Key.Contains(categoryName))
            {
                return(category.Value);
            }
        }

        // Lookup unknown node
        Transform categoryObject = m_UnknownParent.Find(categoryName);

        if (categoryObject != null)
        {
            return(categoryObject);
        }

        // Create to unknown child
        GameObject newObject = new GameObject();

        newObject.name = categoryName;
        CClientCommon.AttachChild(m_UnknownParent, newObject.transform, true);
        newObject.transform.position = Vector3.zero;
        newObject.transform.rotation = Quaternion.identity;
        CClientCommon.NormalizeTransform(newObject);

        return(newObject.transform);
    }
コード例 #13
0
ファイル: UIManager.cs プロジェクト: unstephen/S1_FrameWork
 public void UIDispose()
 {
     for (int i = 0; i < uis.Length; ++i)
     {
         if (uis[i] != null)
         {
             Remove(uis[i]);
         }
     }
     names.Clear();
     foreach (var e in loading.Values)
     {
         CGameUIAsset asset = e as CGameUIAsset;
         CClientCommon.DestroyImmediate(ref asset);
     }
     loading.Clear();
 }
コード例 #14
0
    //---------------------------------------------------------------------
    public static bool Attach(Transform transform, string category, bool inheritLayer)
    {
        Transform categoryObject = GetObject(category);

        if (categoryObject == null)
        {
            return(false);
        }

        CClientCommon.SaveTransform(transform);
        CClientCommon.AttachChild(categoryObject, transform, inheritLayer);
        CClientCommon.RevertTransform(transform);
        if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            UpdateCategoryCount(transform, categoryObject, category);
        }
        return(true);
    }
コード例 #15
0
    protected override void OnCreate()
    {
        this.gameObject = UnityEngine.Object.Instantiate(this.GetOwner().GetAsset()) as GameObject;

        DestoryByTime timeDesCompoment = gameObject.GetComponent <DestoryByTime>();

        if (timeDesCompoment != null)
        {
            start_time    = GameTimer.time;
            duration_time = timeDesCompoment.time;
            CClientCommon.DestroyImmediate(timeDesCompoment);
        }

        if (delayShow)
        {
            DelayShow();
        }

        SetParticleScale(ParticleScale);

        isDone = true;
    }
コード例 #16
0
    protected override void OnDestroy()
    {
        CClientCommon.DestroyImmediate(this.gameObject);

        foreach (var sp in spriteDic.Values)
        {
            if (sp != null)
            {
                sp.Destroy();
            }
        }
        spriteDic.Clear();

        foreach (var tex in imageDic)
        {
            if (tex != null)
            {
                tex.Destroy();
            }
        }
        imageDic.Clear();
    }
コード例 #17
0
    //---------------------------------------------------------------------
    private static GameObject CreateObjectImpl(string category)
    {
        string[] pathItems = category.Split('/');
        if (pathItems.Length == 0)
        {
            return(null);
        }

        GameObject categoryObject = null;
        GameObject parentObject   = null;
        string     currentPath    = "";

        for (int index = 0; index < pathItems.Length; ++index)
        {
            string itemName = pathItems[index];
            if (currentPath.Length == 0)
            {
                currentPath += itemName;
                Transform[] transforms = GameObject.FindObjectsOfType(
                    typeof(Transform)) as Transform[];
                for (int i = 0; i < transforms.Length; ++i)
                {
                    Transform child = transforms[i];
                    if (child.parent != null)
                    {
                        continue;
                    }

                    if (child.name == itemName)
                    {
                        categoryObject = child.gameObject;
                        break;
                    }
                }
            }
            else
            {
                currentPath   += "/" + itemName;
                categoryObject = GameObject.Find(currentPath);
            }

            if (categoryObject == null)
            {
                categoryObject      = new GameObject();
                categoryObject.name = itemName;

                if (parentObject != null)
                {
                    CClientCommon.AttachChild(
                        parentObject.transform,
                        categoryObject.transform, true);
                }
                else
                {
                    //categoryObject.AddComponent<ImmortalComponent>();
                    UnityEngine.Object.DontDestroyOnLoad(categoryObject);
                }
            }

            parentObject = categoryObject;
        }

        if (categoryObject != null)
        {
            m_CategoryMap.Add(category, categoryObject.transform);
        }

        return(categoryObject);
    }