Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.BeginVertical(MalbersEditor.StyleBlue);
            EditorGUILayout.HelpBox("Bow Weapons Properties", MessageType.None);
            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical(MalbersEditor.StyleGray);
            {
                WeaponProperties();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUI.indentLevel++;
                myBow.BonesFoldout = EditorGUILayout.Foldout(myBow.BonesFoldout, new GUIContent("Bow Joints", "AllReferences for the Bow Bones"));

                if (myBow.BonesFoldout)
                {
                    myBow.knot       = (Transform)EditorGUILayout.ObjectField("Knot", myBow.knot, typeof(Transform), true);
                    myBow.arrowPoint = (Transform)EditorGUILayout.ObjectField("Arrow Point", myBow.arrowPoint, typeof(Transform), true);
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(UpperBn, new GUIContent("Upper Chain", "Upper bone chain of the bow"), true);
                    EditorGUILayout.PropertyField(LowerBn, new GUIContent("Lower Chain", "Lower bone chain of the bow"), true);

                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                        myBow.InitializeBow();
                        EditorUtility.SetDirty(myBow);
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                myBow.UpperIndex = EditorGUILayout.Popup("Upper Rot Axis", myBow.UpperIndex, axis);
                myBow.LowerIndex = EditorGUILayout.Popup("Lower Rot Axis", myBow.LowerIndex, axis);
                EditorGUILayout.EndVertical();

                myBow.RotUpperDir = Axis(myBow.UpperIndex);
                myBow.RotLowerDir = Axis(myBow.LowerIndex);

                EditorGUI.BeginChangeCheck();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                myBow.MaxTension = EditorGUILayout.FloatField(new GUIContent("Max Tension", "Max Angle that the Bow can Bent"), myBow.MaxTension);
                myBow.holdTime   = EditorGUILayout.FloatField(new GUIContent("Hold Time", "Time to stretch the string to the Max Tension"), myBow.holdTime);
                EditorGUILayout.EndVertical();
                if (myBow.BowisSet)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    myBow.BowTension = EditorGUILayout.Slider(new GUIContent("Bow Tension", "Bow Tension Normalized"), myBow.BowTension, 0, 1);
                    if (myBow.BowTension > 0)
                    {
                        EditorGUILayout.HelpBox("This is for visual purpose only, please return the Bow Tension to 0", MessageType.Warning);
                    }
                    EditorGUILayout.EndVertical();
                }

                if (EditorGUI.EndChangeCheck())
                {
                    if (myBow.MaxTension < 0)
                    {
                        myBow.MaxTension = 0;
                    }

                    if (myBow.BowisSet)
                    {
                        myBow.BendBow(myBow.BowTension);
                    }



                    EditorUtility.SetDirty(myBow);
                }


                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    myBow.arrow = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Arrow", "Arrow Prefab"), myBow.arrow, typeof(GameObject), false);
                }
                EditorGUILayout.EndVertical();

                SoundsList();

                EventList();
                CheckWeaponID();
            }
            EditorGUILayout.EndVertical();

            EditorUtility.SetDirty(target);

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            MalbersEditor.DrawDescription("Bow Weapons Properties");


            EditorGUILayout.BeginVertical(MalbersEditor.StyleGray);
            {
                CommonWeaponProperties();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUI.indentLevel++;
                EditorGUI.BeginChangeCheck();
                BonesFoldout.boolValue = EditorGUILayout.Foldout(BonesFoldout.boolValue, new GUIContent("Bow Joints", "All References for the Bow Bones"));

                if (BonesFoldout.boolValue)
                {
                    EditorGUILayout.PropertyField(knot);

                    if (knot.objectReferenceValue != null)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PropertyField(DefaultPosKnot, new GUIContent("Def Knot Pos", "Default position of the Knot to return to when the String is on its default position"));
                        if (GUILayout.Button("C", EditorStyles.miniButton, GUILayout.Width(18)))
                        {
                            DefaultPosKnot.vector3Value = (knot.objectReferenceValue as Transform).localPosition;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUILayout.PropertyField(arrowPoint);
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(UpperBn, new GUIContent("Upper Chain", "Upper bone chain of the bow"), true);
                    EditorGUILayout.PropertyField(LowerBn, new GUIContent("Lower Chain", "Lower bone chain of the bow"), true);

                    if (EditorGUI.EndChangeCheck())
                    {
                        m.InitializeBow();
                        EditorUtility.SetDirty(m);
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                UpperIndex.intValue = EditorGUILayout.Popup("Upper Rot Axis", UpperIndex.intValue, axis);
                LowerIndex.intValue = EditorGUILayout.Popup("Lower Rot Axis", LowerIndex.intValue, axis);
                EditorGUILayout.EndVertical();

                RotUpperDir.vector3Value = Axis(UpperIndex.intValue);
                RotLowerDir.vector3Value = Axis(LowerIndex.intValue);

                EditorGUI.BeginChangeCheck();
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    EditorGUILayout.PropertyField(MaxTension, new GUIContent("Max Tension", "Max Angle that the Bow can Bent"));
                    EditorGUILayout.PropertyField(holdTime, new GUIContent("Hold Time", "Time to stretch the string to the Max Tension"));
                    EditorGUILayout.EndVertical();

                    if (BowIsSet.boolValue)
                    {
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                        EditorGUILayout.PropertyField(BowTension, new GUIContent("Bow Tension (V)", "Bow Tension Normalized"));

                        if (BowTension.floatValue > 0)
                        {
                            EditorGUILayout.HelpBox("This is for visual purpose only, please return the Bow Tension to 0", MessageType.Warning);
                        }
                        EditorGUILayout.EndVertical();
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    if (MaxTension.floatValue < 0)
                    {
                        MaxTension.floatValue = 0;
                    }

                    if (BowIsSet.boolValue)
                    {
                        m.BendBow(m.BowTension);
                    }

                    EditorUtility.SetDirty(m);
                }

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("releaseArrow"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("arrow"));
                    // myBow.arrow =(GameObject)  EditorGUILayout.ObjectField(new GUIContent("Arrow", "Arrow Prefab"), myBow.arrow,typeof(GameObject),false );
                }
                EditorGUILayout.EndVertical();

                SoundsList();

                EventList();
                CheckWeaponID();
            }
            EditorGUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "MBow Inspector");
                //  EditorUtility.SetDirty(target);
            }

            serializedObject.ApplyModifiedProperties();
        }