当前位置: 首页>>代码示例>>C#>>正文


C# FastList.EnsureCapacity方法代码示例

本文整理汇总了C#中FastList.EnsureCapacity方法的典型用法代码示例。如果您正苦于以下问题:C# FastList.EnsureCapacity方法的具体用法?C# FastList.EnsureCapacity怎么用?C# FastList.EnsureCapacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FastList的用法示例。


在下文中一共展示了FastList.EnsureCapacity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UserInterface

        public UserInterface()
        {
            instance = this;

            UIView view = GameObject.FindObjectOfType<UIView> ();

            if (view == null)
                return;

            UIComponent bulldozerBar = UIView.Find ("BulldozerBar");

            if (bulldozerBar == null)
                return;

            try {
                XmlSerializer serializer = new XmlSerializer (typeof(XmlData));
                using (StreamReader reader = new StreamReader("V10Bulldoze.xml")) {
                    data = (XmlData)serializer.Deserialize (reader);
                    reader.Close ();
                }
            } catch (FileNotFoundException) {
                // No options file yet
                data = new XmlData ();
                data.needSave = true;
            } catch (Exception e) {
                Debug.Log ("V10Bulldoze: " + e.GetType ().Name + " while reading xml file: " + e.Message + "\n" + e.StackTrace + "\n\n");
                if (e.InnerException != null)
                    Debug.Log ("Caused by: " + e.InnerException.GetType ().Name + ": " + e.InnerException.Message + "\n" + e.InnerException.StackTrace);
                return;
            }

            //1.X -> 1.3
            if (data.version < 1.3d) {
                // Everything has already been setted to its default value, so let's just adjust the version and save.
                data.version = 1.3d;
                data.needSave = true;
            }

            abandonedButton = new GameObject ("V10Bulldoze abandoned button");
            burnedButton = new GameObject ("V10Bulldoze burned button");
            audioButton = new GameObject ("V10Bulldoze audio button");

            Transform parent = bulldozerBar.transform;
            abandonedButton.transform.parent = parent;
            burnedButton.transform.parent = parent;
            audioButton.transform.parent = parent;

            Shader shader = Shader.Find ("UI/Default UI Shader");
            if (shader == null) {
                Debug.Log ("V10Bulldoze: Can't find default UI shader.");
                shader = new Shader ();
                shader.name = "V10Bulldoze dummy shader";
            }

            UITextureAtlas atlas = ScriptableObject.CreateInstance<UITextureAtlas> ();
            atlas.name = "V10Bulldoze Atlas";
            atlas.material = new Material (shader);
            atlas.material.mainTexture = new Texture2D (0, 0, TextureFormat.DXT5, false);

            FastList<Texture2D> list = new FastList<Texture2D> ();
            list.EnsureCapacity (18);

            UIButton button = abandonedButton.AddComponent<UIButton> ();
            button.relativePosition = new Vector3 (7.0f, -57.0f);
            initButton ("AbandonedButton", button, list, data.abandoned, "Demolish Abandoned", view);
            button.atlas = atlas;

            button = burnedButton.AddComponent<UIButton> ();
            button.relativePosition = new Vector3 ((float)(7 + buttonSize + 7), -57.0f);
            initButton ("BurnedButton", button, list, data.burned, "Demolish Burned", view);
            button.atlas = atlas;

            button = audioButton.AddComponent<UIButton> ();
            button.relativePosition = new Vector3 ((float)(7 + buttonSize + 7 + buttonSize + 7), -57.0f);
            initButton ("AudioButton", button, list, !data.disableEffect, "Mute Bulldozing", view);
            button.atlas = atlas;

            atlas.AddTextures (list.ToArray ());
        }
开发者ID:aoighost,项目名称:V10Bulldoze,代码行数:79,代码来源:UserInterface.cs


注:本文中的FastList.EnsureCapacity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。