public static void OnEditorGUI(DMKBulletShooterController shooter)
        {
            EditorGUILayout.BeginVertical();
            {
                //shooter.identifier = EditorGUILayout.TextField("Identifier", shooter.identifier);
                //	shooter.bulletContainer = (GameObject)EditorGUILayout.ObjectField("Bullet Container", shooter.bulletContainer, typeof(GameObject), true);
                EditorGUI.BeginChangeCheck();
                shooter.groupId = EditorGUILayout.IntField("Group Id", shooter.groupId);
                if (EditorGUI.EndChangeCheck())
                {
                    shooter.parentController.RestartCurrentDanmaku();
                }

                EditorGUI.BeginChangeCheck();
                DMKGUIUtility.MakeCurveControl(ref shooter.emissionCooldown, "Emission CD");
                shooter.emissionLength = (int)Mathf.Clamp(EditorGUILayout.IntField("Emission Length", shooter.emissionLength), 0, 999999);
                shooter.interval       = (int)Mathf.Clamp(EditorGUILayout.IntField("Emission Interval", shooter.interval), 0, 999999);
                shooter.startFrame     = (int)Mathf.Clamp(EditorGUILayout.IntField("Start Frame", shooter.startFrame), 0, 999999);
                shooter.overallLength  = (int)Mathf.Clamp(EditorGUILayout.IntField("Overall Length", shooter.overallLength), 0, 999999);
                if (EditorGUI.EndChangeCheck())
                {
                    shooter.DMKInit();
                }

                shooter.simulationCount = (int)Mathf.Clamp(EditorGUILayout.IntField("Simulation Count", shooter.simulationCount), 1, 999999);

                EditorGUILayout.Space();
                shooter.tag = EditorGUILayout.TextField("Tag", shooter.tag);


                shooter.gameObject = (GameObject)EditorGUILayout.ObjectField("Parent Object", shooter.gameObject, typeof(GameObject), true);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Position Offset");
                    shooter.positionOffset.type = (DMKPositionOffsetType)EditorGUILayout.EnumPopup(shooter.positionOffset.type);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);
                    GUILayout.BeginVertical();

                    shooter.positionOffset.OnEditorGUI(false);
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.Separator();
            EditorGUILayout.EndVertical();

            ShooterGUILowerPart(shooter);
        }
示例#2
0
        void DrawVerticalBezier(Vector3 start, Vector3 end, bool drawArrow)
        {
            float tangentOff = (end.y - start.y) / 2;

            if (end.y < start.y)
            {
                //tangentOff = -tangentOff;
                if (drawArrow)
                {
                    end.y += 8;
                }
            }
            else
            {
                if (drawArrow)
                {
                    end.y -= 8;
                }
            }
            Handles.DrawBezier(start,
                               end,
                               start + Vector3.up * tangentOff,
                               end - Vector3.up * tangentOff,
                               Color.yellow,
                               null,
                               3);
            if (drawArrow)
            {
                if (end.y > start.y)
                {
                    DMKGUIUtility.DrawTextureAt(Resources.LoadAssetAtPath <Texture2D>("Assets/Scripts/DanmakuX/Editor/Resources/Icons/arrow_down.png"),
                                                new Rect(end.x - 10,
                                                         end.y - 8,
                                                         20, 20),
                                                Color.yellow);
                }
                else
                {
                    DMKGUIUtility.DrawTextureAt(Resources.LoadAssetAtPath <Texture2D>("Assets/Scripts/DanmakuX/Editor/Resources/Icons/arrow_up.png"),
                                                new Rect(end.x - 10,
                                                         end.y - 12,
                                                         20, 20),
                                                Color.yellow);
                }
            }
        }
示例#3
0
        public override void OnEditorGUI()
        {
            base.OnEditorGUI();

            this.bulletCount = EditorGUILayout.IntField("Way Count", this.bulletCount);
            if (this.bulletCount < 0)
            {
                this.bulletCount = 0;
            }

            EditorGUI.BeginChangeCheck();
            this.trackTarget = EditorGUILayout.Toggle("Facing Target", this.trackTarget);
            if (!this.trackTarget)
            {
                DMKGUIUtility.MakeCurveControl(ref this.startAngle, "Start Angle");
                //this.startAngle = EditorGUILayout.FloatField("Start Angle", this.startAngle);
            }
            else
            {
                this.targetObject = (GameObject)EditorGUILayout.ObjectField("Target", this.targetObject, typeof(GameObject), true);
            }
            DMKGUIUtility.MakeCurveControl(ref this.angleRange, "Angular Range");
            if (EditorGUI.EndChangeCheck())
            {
                this.startAngle.Update(0);
                this.angleRange.Update(0);
                this._currentAngle = this.startAngle.get();
            }

            DMKGUIUtility.MakeCurveControl(ref this.radius, "Emission Radius");

            if (this.startAngle.type == DMKCurvePropertyType.Constant)
            {
                EditorGUI.BeginChangeCheck();
                this.accel1 = EditorGUILayout.FloatField("Acceleration 1", this.accel1);
                if (EditorGUI.EndChangeCheck())
                {
                    this._acceleration = this.accel1;
                }

                this.accel2        = EditorGUILayout.FloatField("Acceleration 2", this.accel2);
                this._acceleration = this.accel1;
            }
        }
示例#4
0
        public static int MakeSimpleList(int selectedIndex, System.Collections.IList entries, Action onSelectionChange, TextAnchor textAlignment = TextAnchor.MiddleCenter)
        {
            if (!Initialized)
            {
                DMKGUIUtility.Init();
            }
            if (entries.Count == 0)
            {
                return(selectedIndex);
            }

            listEntryNormal.alignment = listEntryFocused.alignment = textAlignment;

            GUILayout.BeginVertical(boxStyle);
            int newSelectedIndex = -1;

            {
                for (int index = 0; index < entries.Count; ++index)
                {
                    if (GUILayout.Button(entries[index].ToString(),
                                         selectedIndex == index ? DMKGUIUtility.listEntryFocused : DMKGUIUtility.listEntryNormal))
                    {
                        newSelectedIndex = index;
                    }
                }
            }

            GUILayout.EndVertical();

            int result = newSelectedIndex == -1 ? selectedIndex : newSelectedIndex;

            if (result != selectedIndex)
            {
                onSelectionChange();
            }
            return(result);
        }
示例#5
0
        void DrawShooterInfo(DMKBulletShooterController shooter, Rect windowRect, bool isSubShooter)
        {
            GUI.skin.label.wordWrap = true;

            EditorGUI.BeginChangeCheck();
            shooter.editorEnabled = EditorGUI.Toggle(new Rect(0, windowRect.height / 2, 16, 16), shooter.editorEnabled);
            if (EditorGUI.EndChangeCheck())
            {
                selectedDanmaku.UpdateShooters();
            }

            GUI.Label(new Rect(2, 0, windowRect.width, 16), shooter.DMKName());
            GUI.skin.label.wordWrap = false;

            Sprite sprite = shooter.bulletInfo.bulletSprite;

            if (sprite != null)
            {
                Texture2D tex = sprite.texture;
                if (tex != null)
                {
                    int width  = (int)(Mathf.Clamp(sprite.rect.width, 0, windowRect.height - 16));
                    int height = (int)(Mathf.Clamp(sprite.rect.height, 0, windowRect.height - 16));
                    DMKGUIUtility.DrawTextureWithTexCoordsAndColor(new Rect(Mathf.Clamp((windowRect.width - width) / 2, 0, windowRect.width / 2),
                                                                            16 + Mathf.Clamp((windowRect.height - 16 - height) / 2, 0, windowRect.height / 2),
                                                                            width,
                                                                            height),
                                                                   tex,
                                                                   new Rect((float)sprite.rect.x / tex.width,
                                                                            (float)sprite.rect.y / tex.height,
                                                                            (float)sprite.rect.width / tex.width,
                                                                            (float)sprite.rect.height / tex.height),
                                                                   shooter.bulletInfo.bulletColor);
                }
            }
        }
        static void ShooterGUILowerPart_BulletInfo(DMKBulletShooterController shooter)
        {
            Rect rr = GUILayoutUtility.GetLastRect();

            GUI.Box(new Rect(0, rr.y + rr.height, rr.width, 2),
                    "");
            EditorGUILayout.BeginVertical("");
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical();

                string bulletInfoStr = "Bullet";
                if (!shooter.editorBulletInfoExpanded)
                {
                    bulletInfoStr = String.Format("Bullet Info (Speed = {0}, Accel = {1})",
                                                  shooter.bulletInfo.speed.value,
                                                  shooter.bulletInfo.accel.value,
                                                  shooter.bulletInfo.maxLifetime);
                }
                shooter.editorBulletInfoExpanded = EditorGUILayout.Foldout(shooter.editorBulletInfoExpanded, bulletInfoStr);

                if (shooter.editorBulletInfoExpanded)
                {
                    {
                        EditorGUILayout.BeginVertical();
                        shooter.bulletInfo.bulletSprite = EditorGUILayout.ObjectField("Sprite", shooter.bulletInfo.bulletSprite, typeof(Sprite), false) as Sprite;
                        shooter.bulletInfo.bulletColor  = EditorGUILayout.ColorField("Color", shooter.bulletInfo.bulletColor);
                        EditorGUILayout.EndVertical();
                    }

                    EditorGUILayout.Separator();

                    DMKBulletInfo bulletInfo = shooter.bulletInfo;
                    DMKGUIUtility.MakeCurveControl(ref bulletInfo.speed, "Speed");
                    DMKGUIUtility.MakeCurveControl(ref bulletInfo.accel, "Acceleration");
                    DMKGUIUtility.MakeCurveControl(ref bulletInfo.angularAccel, "Angular Accel");

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Scale");
                        bulletInfo.useScaleCurve = DMKGUIUtility.MakeCurveToggle(bulletInfo.useScaleCurve);
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(32);
                        GUILayout.BeginVertical();

                        if (bulletInfo.useScaleCurve)
                        {
                            bulletInfo.scaleCurveX = EditorGUILayout.CurveField("Scale X", bulletInfo.scaleCurveX);
                            bulletInfo.scaleCurveY = EditorGUILayout.CurveField("Scale Y", bulletInfo.scaleCurveY);
                        }
                        else
                        {
                            bulletInfo.scale = EditorGUILayout.Vector2Field("", bulletInfo.scale);
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();

                    shooter.bulletInfo.damage      = EditorGUILayout.IntField("Damage", shooter.bulletInfo.damage);
                    shooter.bulletInfo.maxLifetime = EditorGUILayout.IntField("Lifetime (Frame)", shooter.bulletInfo.maxLifetime);
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();
        }