コード例 #1
0
        static void CreateImage()
        {
            Object[] interfaceGroups = FindObjectsOfType(typeof(InterfaceGroup));

            GameObject @object = new GameObject("Image");

            @object.AddComponent <Image>();
            @object.AddComponent <InterfaceElement>();
            @object.AddComponent <CanvasGroup>();

            if (interfaceGroups.Length > 0)
            {
                InterfaceGroup interfaceGroup = interfaceGroups[interfaceGroups.Length - 1] as InterfaceGroup;
                @object.transform.SetParent(interfaceGroup.transform, false);
                interfaceGroup.Build();
            }
        }
コード例 #2
0
        static void CreateScrollbar()
        {
            Object[] interfaceGroups = FindObjectsOfType(typeof(InterfaceGroup));

            GameObject @object = new GameObject("Scroll Bar");

            @object.AddComponent <Scrollbar>();
            @object.AddComponent <InterfaceElement>();
            @object.AddComponent <InterfaceAnimation>();
            @object.AddComponent <RectTransform>();
            @object.AddComponent <CanvasGroup>();

            if (interfaceGroups.Length > 0)
            {
                InterfaceGroup interfaceGroup = interfaceGroups[interfaceGroups.Length - 1] as InterfaceGroup;
                @object.transform.SetParent(interfaceGroup.transform, false);
                interfaceGroup.Build();
            }
        }
コード例 #3
0
        static void CreateText()
        {
            Object[] interfaceGroups = FindObjectsOfType(typeof(InterfaceGroup));

            GameObject @object = new GameObject("Text");

            @object.AddComponent <InterfaceElement>();
            @object.AddComponent <RectTransform>();
            @object.AddComponent <CanvasGroup>();

            Text text = @object.AddComponent <Text>();

            text.text = "New Text";

            if (interfaceGroups.Length > 0)
            {
                InterfaceGroup interfaceGroup = interfaceGroups[interfaceGroups.Length - 1] as InterfaceGroup;
                @object.transform.SetParent(interfaceGroup.transform, false);
                interfaceGroup.Build();
            }
        }
コード例 #4
0
        //Updates values for the Interfacegroup based on the inspector values
        public override void OnInspectorGUI()
        {
            InterfaceGroup interfaceGroup = (InterfaceGroup)target;

            interfaceGroup.animationInterval = EditorGUILayout.FloatField("Animation Interval", interfaceGroup.animationInterval);
            interfaceGroup.layout            = (InterfaceGroup.Layout)EditorGUILayout.EnumPopup("Layout", interfaceGroup.layout);
            interfaceGroup.origin            = EditorGUILayout.Vector3Field("Origin", interfaceGroup.origin);

            EditorGUILayout.Space();

            interfaceGroup.cellSize = EditorGUILayout.IntField("Elements Per Row", interfaceGroup.cellSize);
            interfaceGroup.flipX    = EditorGUILayout.Toggle("Flip X", interfaceGroup.flipX);
            interfaceGroup.flipY    = EditorGUILayout.Toggle("Flip Y", interfaceGroup.flipY);

            EditorGUILayout.Space();

            interfaceGroup.dimension = EditorGUILayout.Vector2Field("Dimension", interfaceGroup.dimension);
            interfaceGroup.margin    = EditorGUILayout.Vector2Field("Margin", interfaceGroup.margin);
            interfaceGroup.scale     = EditorGUILayout.Vector2Field("Scale", interfaceGroup.scale);
            interfaceGroup.rotation  = EditorGUILayout.Vector2Field("Rotation", interfaceGroup.rotation);

            interfaceGroup.Build();
        }