Exemplo n.º 1
0
    // This function is called every editor gui update. In here we are diong our magic to show all to the user in a nice way.
    public override void OnInspectorGUI()
    {
        //Setting styles
        if (_descBoxStyle == null)
        {
            _descBoxStyle                  = new GUIStyle(GUI.skin.FindStyle("Box"));
            _descBoxStyle.alignment        = TextAnchor.UpperLeft;
            _descBoxStyle.normal.textColor = Color.white;
            _descBoxStyle.stretchWidth     = true;

            _bigBoxStyle                   = new GUIStyle(GUI.skin.FindStyle("Box"));
            _bigBoxStyle.alignment         = TextAnchor.UpperLeft;
            _bigBoxStyle.normal.textColor  = Color.white;
            _bigBoxStyle.stretchHeight     = true;
            _bigBoxStyle.normal.background = (Texture2D)Resources.Load("SourceBack");

            _popupStyle               = new GUIStyle(GUI.skin.FindStyle("Popup"));
            _popupStyle.fontStyle     = (FontStyle.Normal);
            _popupStyle.stretchHeight = true;
        }

        EditorGUIUtility.LookLikeInspector();

        serializedObject.Update();         // update the serialized object since the last time this method was called.

        BaseAction myTarget = (BaseAction)target;

        myTarget.UpdateInspector();

        SerializedProperty script = serializedObject.FindProperty("m_Script");

        EditorGUILayout.PropertyField(script, new GUIContent("Script", myTarget.GetActionDescription()));


        //Show first public visible fields with the Attribute "ShowAtfirst"
        SerializedProperty prop = serializedObject.GetIterator();

        prop.NextVisible(true);
        do
        {
            if (ShouldShowFirst(prop))
            {
                EditorGUILayout.PropertyField(prop, true);
            }
        } while (prop.NextVisible(false));

        //then show Triggers


        Rect rect = EditorGUILayout.BeginVertical();

        GUI.Box(rect, "", _bigBoxStyle);

        if (myTarget.IsSupportCustomTriggers())
        {
            GUILayout.Space(5);

            // Add Trigger row - Combo-box + Add Button
            Rect addTriggerRect = EditorGUILayout.BeginHorizontal();
            {
                if (_triggerToAdd != null)
                {
                    // If user pressed on "Add" button -  add the selected trigger to the action's supported triggers
                    _supportedTriggers.InsertArrayElementAtIndex(0);
                    _supportedTriggers.GetArrayElementAtIndex(0).objectReferenceValue = myTarget.AddHiddenComponent(_triggerToAdd);

                    ((Trigger)_supportedTriggers.GetArrayElementAtIndex(0).objectReferenceValue).CleanRules();

                    _triggerToAdd = null;
                }

                GUILayout.Box("Add Triger", _popupStyle);

                var evt = Event.current;
                if (evt.type == EventType.mouseDown)
                {
                    //Getting all Triggers
                    List <System.Type> possibleTriggers = myTarget.GetSupprtedTriggers();

                    var mousePos = evt.mousePosition;
                    if (addTriggerRect.Contains(mousePos))
                    {
                        // Now create the menu, add items and show it
                        var menu = new GenericMenu();
                        for (int i = 0; i < possibleTriggers.Count; i++)
                        {
                            string triggerFriendlyName = "";
                            if (!_friendlyNames.ContainsKey(possibleTriggers[i].FullName))
                            {
                                GameObject g           = new GameObject("temp");
                                Trigger    triggerTemp = (Trigger)g.AddComponent(possibleTriggers[i]);
                                _friendlyNames.Add(possibleTriggers[i].FullName, triggerTemp.FriendlyName);
                                DestroyImmediate(g);
                            }

                            triggerFriendlyName = _friendlyNames[possibleTriggers[i].FullName];


                            menu.AddItem(new GUIContent(triggerFriendlyName), false, AddTrigger, possibleTriggers[i]);
                        }

                        menu.ShowAsContext();
                        evt.Use();
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        // go over all the Action's supported triggers and add them to the inspector.
        for (int i = 0; i < _supportedTriggers.arraySize; i++)
        {
            //Get Trigger and update rules
            Trigger trigger = (Trigger)_supportedTriggers.GetArrayElementAtIndex(i).objectReferenceValue;
            if (trigger == null)
            {
                ((BaseAction)target).InitializeSupportedTriggers();
                EditorGUILayout.EndVertical();
                return;
            }

            // Trigger Row - Foldout + Reset trigger button + Delete trigger
            Rect triggerRect = EditorGUILayout.BeginHorizontal();
            {
                trigger.FoldoutOpen = GUIUtils.Foldout(trigger.FoldoutOpen, trigger.FriendlyName);
                if (trigger.FoldoutOpen)
                {
                    List <System.Type> supprtedRules1 = trigger.GetSupportedRules();
                    Rect rectRuleAddButton            = EditorGUILayout.BeginHorizontal();

                    GUILayout.Box("Add", _popupStyle, GUILayout.Width(50));
                    EditorGUILayout.EndHorizontal();

                    GUILayout.FlexibleSpace();

                    var evt = Event.current;
                    if (evt.type == EventType.mouseDown)
                    {
                        var mousePos = evt.mousePosition;
                        if (rectRuleAddButton.Contains(mousePos))
                        {
                            // Now create the menu, add items and show it
                            var menu1 = new GenericMenu();
                            for (int ri = 0; ri < supprtedRules1.Count(); ri++)
                            {
                                string ruleFriendlyName = "";
                                if (!_friendlyNames.ContainsKey(supprtedRules1[ri].FullName))
                                {
                                    GameObject g        = new GameObject("temp");
                                    BaseRule   ruleTemp = (BaseRule)g.AddComponent(supprtedRules1[ri]);
                                    _friendlyNames.Add(supprtedRules1[ri].FullName, ruleTemp.FriendlyName);
                                    DestroyImmediate(g);
                                }

                                ruleFriendlyName = _friendlyNames[supprtedRules1[ri].FullName];

                                menu1.AddItem(new GUIContent(ruleFriendlyName), false, AddRule, supprtedRules1[ri]);
                            }

                            menu1.ShowAsContext();
                            evt.Use();

                            _triggerToAddRuleTo = trigger;
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            SetTriggersContextMenu(triggerRect, myTarget, trigger);

            // show trigger's rules if opened
            if (trigger.FoldoutOpen)
            {
                SerializedObject   obj   = new SerializedObject(_supportedTriggers.GetArrayElementAtIndex(i).objectReferenceValue);
                SerializedProperty rules = obj.FindProperty("Rules");

                if (true)
                {
                    // Add Trigger row - Combo-box + Add Button
                    EditorGUILayout.BeginHorizontal();
                    {
                        //Adding combo-box control to the inspector with the list of triggers.
                        if (_triggerToAddRuleTo == trigger && _ruleToAdd != null)
                        {
                            // If user pressed on "Add" button -  add the selected trigger to the action's supported triggers
                            rules.InsertArrayElementAtIndex(0);
                            rules.GetArrayElementAtIndex(0).objectReferenceValue = myTarget.AddHiddenComponent(_ruleToAdd);

                            // initialize rules
                            _ruleToAdd          = null;
                            _triggerToAddRuleTo = null;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    GUILayout.Space(5);
                }



                for (int j = 0; j < rules.arraySize; j++)
                {
                    BaseRule rule = (BaseRule)rules.GetArrayElementAtIndex(j).objectReferenceValue;
                    DrawRuleInspector(rule);

                    //Reset Rule
                    if (_ruleToReset != null && _ruleToReset == rule)
                    {
                        rule.ActionOwner = null;
                        rules.GetArrayElementAtIndex(j).objectReferenceValue = myTarget.AddHiddenComponent(_ruleToReset.GetType());
                        // Save folded state
                        ((BaseRule)rules.GetArrayElementAtIndex(j).objectReferenceValue).FoldoutOpen = rule.FoldoutOpen;

                        _ruleToReset = null;
                    }

                    //Remove Rule
                    if (_ruleToRemove != null && _ruleToRemove == rule)
                    {
                        // delete the trigger and reorganize the array
                        var r = rules.GetArrayElementAtIndex(j).objectReferenceValue;
                        rules.DeleteArrayElementAtIndex(j);
                        ((BaseRule)r).ActionOwner = null;
                        for (int k = j; k < rules.arraySize - 1; k++)
                        {
                            rules.MoveArrayElement(k + 1, k);
                        }
                        rules.arraySize--;
                        _ruleToRemove = null;
                    }
                }

                //Save changes to the rule
                obj.ApplyModifiedProperties();
            }

            // Reset Trigger
            if (_triggerToReset != null && _triggerToReset == trigger)
            {
                trigger.ActionOwner = null;
                foreach (BaseRule r in trigger.Rules)
                {
                    r.ActionOwner = null;
                }
                _supportedTriggers.GetArrayElementAtIndex(i).objectReferenceValue = myTarget.AddHiddenComponent(trigger.GetType());

                Trigger oldTrigger = trigger;
                trigger = (Trigger)_supportedTriggers.GetArrayElementAtIndex(i).objectReferenceValue;

                trigger.CleanRules();
                //trigger.SetDefaults(myTarget);
                myTarget.SetDefaultTriggerValues(i, trigger);

                // Save folded state
                trigger.FoldoutOpen = oldTrigger.FoldoutOpen;


                _triggerToReset = null;
                break;
            }

            // Remove Trigger
            if (_triggerToRemove != null && _triggerToRemove == trigger)
            {
                // delete the trigger and reorganize the array

                _supportedTriggers.DeleteArrayElementAtIndex(i);
                trigger.ActionOwner = null;
                if (trigger.Rules != null)
                {
                    foreach (BaseRule r in trigger.Rules)
                    {
                        if (r != null)
                        {
                            r.ActionOwner = null;
                        }
                    }
                }
                for (int j = i; j < _supportedTriggers.arraySize - 1; j++)
                {
                    _supportedTriggers.MoveArrayElement(j + 1, j);
                }
                _supportedTriggers.arraySize--;
                break;
            }
        }
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        // Draw the rest of the control except several predefined fields or the fields which are marked as show first
        prop = serializedObject.GetIterator();

        prop.NextVisible(true);
        do
        {
            if (prop.name != "m_Script" && !ShouldShowFirst(prop))
            {
                EditorGUILayout.PropertyField(prop, true);
            }
        } while (prop.NextVisible(false));


        //Save changes to the Action Script
        serializedObject.ApplyModifiedProperties();
    }
        public static void TagsMaskField(GUIContent changeLabel, GUIContent setLabel, ref Pathfinding.TagMask value)
        {
            GUILayout.BeginHorizontal();

            //Debug.Log (value.ToString ());
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            EditorGUIUtility.LookLikeControls();
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            EditorGUILayout.PrefixLabel(changeLabel, EditorStyles.layerMaskField);
            //GUILayout.FlexibleSpace ();
            //Rect r = GUILayoutUtility.GetLastRect ();

            string text = "";
            if (value.tagsChange == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsChange == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsChange, 2);
            }

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                //Debug.Log ("pre");
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Everything"), value.tagsChange == ~0, value.SetValues, new Pathfinding.TagMask(~0, value.tagsSet));
                menu.AddItem(new GUIContent("Nothing"), value.tagsChange == 0, value.SetValues, new Pathfinding.TagMask(0, value.tagsSet));

                for (int i = 0; i < 32; i++)
                {
                    bool on = (value.tagsChange >> i & 0x1) != 0;
                    Pathfinding.TagMask result = new Pathfinding.TagMask(on ? value.tagsChange & ~(1 << i) : value.tagsChange | 1 << i, value.tagsSet);
                    menu.AddItem(new GUIContent("" + i), on, value.SetValues, result);
                    //value.SetValues (result);
                }

                menu.ShowAsContext();

                Event.current.Use();
                //Debug.Log ("Post");
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();



            GUILayout.BeginHorizontal();

            //Debug.Log (value.ToString ());
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            EditorGUIUtility.LookLikeControls();
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            EditorGUILayout.PrefixLabel(setLabel, EditorStyles.layerMaskField);
            //GUILayout.FlexibleSpace ();
            //r = GUILayoutUtility.GetLastRect ();

            text = "";
            if (value.tagsSet == 0)
            {
                text = "Nothing";
            }
            else if (value.tagsSet == ~0)
            {
                text = "Everything";
            }
            else
            {
                text = System.Convert.ToString(value.tagsSet, 2);
            }

            if (GUILayout.Button(text, EditorStyles.layerMaskField, GUILayout.ExpandWidth(true)))
            {
                //Debug.Log ("pre");
                GenericMenu menu = new GenericMenu();

                if (value.tagsChange != 0)
                {
                    menu.AddItem(new GUIContent("Everything"), value.tagsSet == ~0, value.SetValues, new Pathfinding.TagMask(value.tagsChange, ~0));
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Everything"));
                }

                menu.AddItem(new GUIContent("Nothing"), value.tagsSet == 0, value.SetValues, new Pathfinding.TagMask(value.tagsChange, 0));

                for (int i = 0; i < 32; i++)
                {
                    bool enabled = (value.tagsChange >> i & 0x1) != 0;
                    bool on      = (value.tagsSet >> i & 0x1) != 0;

                    Pathfinding.TagMask result = new Pathfinding.TagMask(value.tagsChange, on ? value.tagsSet & ~(1 << i) : value.tagsSet | 1 << i);

                    if (enabled)
                    {
                        menu.AddItem(new GUIContent("" + i), on, value.SetValues, result);
                    }
                    else
                    {
                        menu.AddDisabledItem(new GUIContent("" + i));
                    }

                    //value.SetValues (result);
                }

                menu.ShowAsContext();

                Event.current.Use();
                //Debug.Log ("Post");
            }

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif
            GUILayout.EndHorizontal();


            //return value;
        }
Exemplo n.º 3
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    public override void OnInspectorGUI()
    {
        // ========================================================
        // Base GUI
        // ========================================================

        base.OnInspectorGUI();
        GUILayout.Space(20);

        // ========================================================
        // init values
        // ========================================================

        //
        bool needRebuild = false;

        editSprite.spanim = editSprite.GetComponent <exSpriteAnimation>();

        // get ElementInfo first
        Texture2D editTexture = exEditorHelper.LoadAssetFromGUID <Texture2D>(editSprite.textureGUID);

        // ========================================================
        // Texture preview (input)
        // ========================================================

        bool textureChanged = false;

        GUI.enabled = !inAnimMode;
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        EditorGUIUtility.LookLikeControls();
        Texture2D newTexture = (Texture2D)EditorGUILayout.ObjectField(editTexture
                                                                      , typeof(Texture2D)
                                                                      , false
                                                                      , GUILayout.Width(100)
                                                                      , GUILayout.Height(100)
                                                                      );

        EditorGUIUtility.LookLikeInspector();
        if (newTexture != editTexture)
        {
            editTexture            = newTexture;
            editSprite.textureGUID = exEditorHelper.AssetToGUID(editTexture);
            textureChanged         = true;
            GUI.changed            = true;
        }
        GUILayout.Space(10);
        GUILayout.BeginVertical();
        GUILayout.Space(90);
        GUILayout.Label(editTexture ? editTexture.name : "None");
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        GUI.enabled = true;

        // ========================================================
        // get atlas element info from atlas database
        // ========================================================

        exAtlas editAtlas = null;
        int     editIndex = -1;

        exAtlasDB.ElementInfo elInfo = exAtlasDB.GetElementInfo(editSprite.textureGUID);
        if (elInfo != null)
        {
            editAtlas = exEditorHelper.LoadAssetFromGUID <exAtlas>(elInfo.guidAtlas);
            editIndex = elInfo.indexInAtlas;
        }
        bool useAtlas = editAtlas != null && editIndex != -1;

        // get atlas and index from textureGUID
        if (!EditorApplication.isPlaying)
        {
            // if we don't use atlas and current edit target use atlas, clear it.
            if (editSprite.useAtlas != useAtlas)
            {
                editSprite.Clear();
            }

            // if we use atlas, check if the atlas,index changes
            if (useAtlas)
            {
                if (editAtlas != editSprite.atlas ||
                    editIndex != editSprite.index)
                {
                    editSprite.SetSprite(editAtlas, editIndex);
                    GUI.changed = true;
                }
            }

            // check if we are first time assignment
            if (useAtlas || editTexture != null)
            {
                if (isPrefab == false && editSprite.meshFilter.sharedMesh == null)
                {
                    needRebuild = true;
                }
            }
        }

        // ========================================================
        // get trimTexture
        // ========================================================

        GUI.enabled = !inAnimMode && !useAtlas;
        bool newTrimTexture = EditorGUILayout.Toggle("Trim Texture", editSprite.trimTexture);

        if (!useAtlas &&
            (textureChanged || newTrimTexture != editSprite.trimTexture))
        {
            editSprite.GetComponent <Renderer>().sharedMaterial = exEditorHelper.GetDefaultMaterial(editTexture, editTexture.name);
            editSprite.trimTexture = newTrimTexture;

            // get trimUV
            Rect trimUV = new Rect(0, 0, 1, 1);
            if (editTexture != null)
            {
                if (editSprite.trimTexture)
                {
                    if (exTextureHelper.IsValidForAtlas(editTexture) == false)
                    {
                        exTextureHelper.ImportTextureForAtlas(editTexture);
                    }
                    trimUV = exTextureHelper.GetTrimTextureRect(editTexture);
                    trimUV = new Rect(trimUV.x / editTexture.width,
                                      (editTexture.height - trimUV.height - trimUV.y) / editTexture.height,
                                      trimUV.width / editTexture.width,
                                      trimUV.height / editTexture.height);
                }

                if (editSprite.customSize == false)
                {
                    editSprite.width  = trimUV.width * editTexture.width;
                    editSprite.height = trimUV.height * editTexture.height;
                }
            }
            editSprite.trimUV       = trimUV;
            editSprite.updateFlags |= exPlane.UpdateFlags.UV;
            editSprite.updateFlags |= exPlane.UpdateFlags.Vertex;
        }
        GUI.enabled = true;

        // ========================================================
        // color
        // ========================================================

        editSprite.color = EditorGUILayout.ColorField("Color", editSprite.color);

        // ========================================================
        // atlas & index
        // ========================================================

        GUILayout.BeginHorizontal();
        GUI.enabled = false;
        EditorGUILayout.ObjectField("Atlas"
                                    , editSprite.atlas
                                    , typeof(exAtlas)
                                    , false
                                    );
        GUI.enabled = true;

        GUI.enabled = !inAnimMode;
        if (GUILayout.Button("Edit...", GUILayout.Width(40), GUILayout.Height(15)))
        {
            exAtlasEditor editor = exAtlasEditor.NewWindow();
            editor.Edit(editSprite.atlas);
        }
        GUI.enabled = true;
        GUILayout.EndHorizontal();

        GUI.enabled = false;
        EditorGUILayout.IntField("Index", editSprite.index);
        GUI.enabled = true;

        // ========================================================
        // custom size
        // ========================================================

        GUI.enabled           = !inAnimMode;
        editSprite.customSize = EditorGUILayout.Toggle("Custom Size", editSprite.customSize);
        GUI.enabled           = true;

        // ========================================================
        // width & height
        // ========================================================

        ++EditorGUI.indentLevel;
        GUI.enabled = !inAnimMode && editSprite.customSize;
        // width
        float newWidth = EditorGUILayout.FloatField("Width", editSprite.width);

        if (newWidth != editSprite.width)
        {
            if (newWidth < 1.0f)
            {
                newWidth = 1.0f;
            }
            editSprite.width = newWidth;
        }

        // height
        float newHeight = EditorGUILayout.FloatField("Height", editSprite.height);

        if (newHeight != editSprite.height)
        {
            if (newHeight < 1.0f)
            {
                newHeight = 1.0f;
            }
            editSprite.height = newHeight;
        }
        --EditorGUI.indentLevel;

        // ========================================================
        // Reset to original
        // ========================================================

        GUILayout.BeginHorizontal();
        GUILayout.Space(30);
        if (GUILayout.Button("Reset", GUILayout.Width(50)))
        {
            if (useAtlas)
            {
                exAtlas.Element el = editAtlas.elements[editIndex];
                editSprite.width  = el.trimRect.width;
                editSprite.height = el.trimRect.height;
            }
            else if (editTexture)
            {
                editSprite.width  = editSprite.trimUV.width * editTexture.width;
                editSprite.height = editSprite.trimUV.height * editTexture.height;
            }
            GUI.changed = true;
        }
        GUILayout.EndHorizontal();
        GUI.enabled = true;

        // ========================================================
        // Rebuild button
        // ========================================================

        GUI.enabled = !inAnimMode;
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Rebuild...", GUILayout.Height(20)))
        {
            needRebuild = true;
        }
        GUILayout.EndHorizontal();
        GUI.enabled = true;
        GUILayout.Space(5);

        // if dirty, build it.
        if (!EditorApplication.isPlaying && !AnimationUtility.InAnimationMode())
        {
            if (needRebuild)
            {
                EditorUtility.ClearProgressBar();
                editSprite.Build(editTexture);
            }
            else if (GUI.changed)
            {
                if (editSprite.meshFilter.sharedMesh != null)
                {
                    editSprite.UpdateMesh(editSprite.meshFilter.sharedMesh);
                }
                EditorUtility.SetDirty(editSprite);
            }
        }
    }
Exemplo n.º 4
0
    /*
     */
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        tk2dSpineSkeletonDataAsset asset = target as tk2dSpineSkeletonDataAsset;

        EditorGUIUtility.LookLikeInspector();
        sprites = EditorGUILayout.ObjectField("Sprites", sprites, typeof(tk2dSpriteCollection), false) as tk2dSpriteCollection;

        if (sprites != null)
        {
            SerializedProperty spritesData = serializedObject.FindProperty("spritesData");
            spritesData.objectReferenceValue = sprites.spriteCollection;

            SerializedProperty normalGenerationMode = serializedObject.FindProperty("normalGenerationMode");
            normalGenerationMode.enumValueIndex = (int)sprites.normalGenerationMode;
        }
        else
        {
            SerializedProperty spritesData = serializedObject.FindProperty("spritesData");
            spritesData.objectReferenceValue = null;

            SerializedProperty normalGenerationMode = serializedObject.FindProperty("normalGenerationMode");
            normalGenerationMode.enumValueIndex = (int)tk2dSpriteCollection.NormalGenerationMode.None;
        }

        EditorGUILayout.PropertyField(skeletonJSON);

        SkeletonData skeletonData = asset.GetSkeletonData();

        if (skeletonData != null)
        {
            showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
            if (showAnimationStateData)
            {
                String[] animations = new String[skeletonData.Animations.Count];
                for (int i = 0; i < animations.Length; i++)
                {
                    animations[i] = skeletonData.Animations[i].Name;
                }

                for (int i = 0; i < fromAnimation.arraySize; i++)
                {
                    SerializedProperty from         = fromAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty to           = toAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty durationProp = duration.GetArrayElementAtIndex(i);

                    EditorGUILayout.BeginHorizontal();

                    from.stringValue        = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)];
                    to.stringValue          = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)];
                    durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue);

                    if (GUILayout.Button("Delete"))
                    {
                        duration.DeleteArrayElementAtIndex(i);
                        toAnimation.DeleteArrayElementAtIndex(i);
                        fromAnimation.DeleteArrayElementAtIndex(i);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();

                if (GUILayout.Button("Add Mix"))
                {
                    duration.arraySize++;
                    toAnimation.arraySize++;
                    fromAnimation.arraySize++;
                }

                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 5
0
    override public void OnInspectorGUI()
    {
        serializedObject.Update();
        SkeletonDataAsset asset = (SkeletonDataAsset)target;

        EditorGUIUtility.LookLikeInspector();

        tk2dSpriteCollection sprites = EditorGUILayout.ObjectField("Sprite Collection", asset.spriteCollection, typeof(tk2dSpriteCollection), false) as tk2dSpriteCollection;

        if (sprites != null)
        {
            spriteCollection.objectReferenceValue = sprites.spriteCollection;
        }

        EditorGUILayout.PropertyField(skeletonJSON);
        EditorGUILayout.PropertyField(scale);

        SkeletonData skeletonData = asset.GetSkeletonData(true);

        if (skeletonData != null)
        {
            showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
            if (showAnimationStateData)
            {
                // Animation names.
                String[] animations = new String[skeletonData.Animations.Count];
                for (int i = 0; i < animations.Length; i++)
                {
                    animations[i] = skeletonData.Animations[i].Name;
                }

                for (int i = 0; i < fromAnimation.arraySize; i++)
                {
                    SerializedProperty from         = fromAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty to           = toAnimation.GetArrayElementAtIndex(i);
                    SerializedProperty durationProp = duration.GetArrayElementAtIndex(i);
                    EditorGUILayout.BeginHorizontal();
                    from.stringValue        = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)];
                    to.stringValue          = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)];
                    durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue);
                    if (GUILayout.Button("Delete"))
                    {
                        duration.DeleteArrayElementAtIndex(i);
                        toAnimation.DeleteArrayElementAtIndex(i);
                        fromAnimation.DeleteArrayElementAtIndex(i);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.Space();
                if (GUILayout.Button("Add Mix"))
                {
                    duration.arraySize++;
                    toAnimation.arraySize++;
                    fromAnimation.arraySize++;
                }
                EditorGUILayout.Space();
                EditorGUILayout.EndHorizontal();
            }
        }

        if (!Application.isPlaying)
        {
            if (serializedObject.ApplyModifiedProperties() ||
                (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
                )
            {
                asset.Clear();
            }
        }
    }
Exemplo n.º 6
0
    override public void OnInspectorGUI()
    {
        serializedObject.Update();

        //Instance of our RPGTalk class
        CustomTalk rpgTalk = (CustomTalk)target;

        EditorGUIUtility.LookLikeInspector();
        EditorGUI.BeginChangeCheck();

        EditorGUILayout.LabelField("Human Talk!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("humanTalk"), GUIContent.none);
        EditorGUILayout.LabelField("Monster Talk!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("monsterTalk"), GUIContent.none);


        EditorGUILayout.LabelField("Human Talk Reac!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("humanTalkReac"), GUIContent.none);
        EditorGUILayout.LabelField("Monster Talk Reac!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("monsterTalkReac"), GUIContent.none);

        EditorGUILayout.LabelField("Monster Fail attack  Reac!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("humanFailAttack"), GUIContent.none);

        EditorGUILayout.LabelField("MonsterInit Talk!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("monsterInitTalk"), GUIContent.none);

        EditorGUILayout.LabelField("Bard Talk!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("bardTalk"), GUIContent.none);
        EditorGUILayout.LabelField("Ed Talk!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("edTalk"), GUIContent.none);

        EditorGUILayout.LabelField("humanAnchor");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("humanAnchor"), GUIContent.none);
        EditorGUILayout.LabelField("monsterAnchor");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("monsterAnchor"), GUIContent.none);

        //  EditorGUILayout.LabelField("ReactionTalk");
        //   EditorGUILayout.PropertyField(serializedObject.FindProperty("reactTalk"), GUIContent.none);


        EditorGUILayout.LabelField("Put below the Text file to be parsed and become the talks!");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("txtToParse"), GUIContent.none);
        if (serializedObject.FindProperty("txtToParse").objectReferenceValue == null)
        {
            EditorGUILayout.HelpBox("RPGTalk needs a TXT file to retrieve the lines from", MessageType.Error, true);
        }

        EditorGUILayout.PropertyField(serializedObject.FindProperty("showWithDialog"), true);
        if (serializedObject.FindProperty("showWithDialog").arraySize == 0)
        {
            EditorGUILayout.HelpBox("Not a single element to be shown with the Talk? Not even the Canvas?" +
                                    "Are you sure that is the correct bahaviour?", MessageType.Warning, true);
        }

        //  rpgTalk.isReaction = GUILayout.Toggle(rpgTalk.isReaction, "Is Reation?");

        EditorGUILayout.BeginVertical((GUIStyle)"HelpBox");

        EditorGUILayout.LabelField("Regular Options:", EditorStyles.boldLabel);
        rpgTalk.startOnAwake = GUILayout.Toggle(rpgTalk.startOnAwake, "Start On Awake?");
        rpgTalk.dialoger     = GUILayout.Toggle(rpgTalk.dialoger, "Should show the name of the talker?");

        rpgTalk.shouldUsePhotos    = GUILayout.Toggle(rpgTalk.shouldUsePhotos, "Should there be the photo of the talker?");
        rpgTalk.shouldStayOnScreen = GUILayout.Toggle(rpgTalk.shouldStayOnScreen, "Should the canvas stay on screen after the talk ended?");
        rpgTalk.shouldFollow       = GUILayout.Toggle(rpgTalk.shouldFollow, "Should the canvas follow someone?");
        if (rpgTalk.shouldFollow)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField("Who should it follow? Should there be an Offset?");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("follow"), GUIContent.none);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("followOffset"), GUIContent.none);
            EditorGUILayout.EndHorizontal();

            if (rpgTalk.shouldFollow && serializedObject.FindProperty("follow").objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("You didn't set anyone to follow!", MessageType.Error, true);
            }

            EditorGUILayout.LabelField("The object that follows should be Billboard? Based on which camera?");
            EditorGUILayout.BeginHorizontal();
            rpgTalk.billboard = GUILayout.Toggle(rpgTalk.billboard, "Billboard?");
            if (rpgTalk.billboard)
            {
                rpgTalk.mainCamera = GUILayout.Toggle(rpgTalk.mainCamera, "Based on Main Camera?");
            }
            EditorGUILayout.EndHorizontal();
            if (rpgTalk.billboard && !rpgTalk.mainCamera)
            {
                EditorGUILayout.LabelField("What camera should the Billboard be based on?");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("otherCamera"), GUIContent.none);
            }
            EditorGUI.indentLevel--;
        }
        rpgTalk.enableQuickSkip = GUILayout.Toggle(rpgTalk.enableQuickSkip, "Enable QuickStep (the player can jump the animation)?");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("textSpeed"));

        rpgTalk.passWithMouse = GUILayout.Toggle(rpgTalk.passWithMouse, "Pass the Talk with Mouse Click?");
        EditorGUILayout.LabelField("The Talk can also be passed with some button set on Project Settings > Input:");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("passWithInputButton"), GUIContent.none);
        if (!rpgTalk.passWithMouse && serializedObject.FindProperty("passWithInputButton").stringValue == "")
        {
            EditorGUILayout.HelpBox("There is no condition to pass the Talk. Is it really the expected behaviour?", MessageType.Warning, true);
        }

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("RPGTalk can try to make a Word Wrap for long texts in the same line.");
        rpgTalk.wordWrap = GUILayout.Toggle(rpgTalk.wordWrap, "Word Wrap?");
        if (rpgTalk.wordWrap)
        {
            EditorGUILayout.LabelField("Set manually the maximum chars in Width/Height that fit in the screen:");
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(serializedObject.FindProperty("maxCharInWidth"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("maxCharInHeight"));
            EditorGUI.indentLevel--;
        }

        EditorGUILayout.EndVertical();


        //create a nice box with round edges.
        EditorGUILayout.BeginVertical((GUIStyle)"HelpBox");
        EditorGUILayout.LabelField("Interface:", EditorStyles.boldLabel);
        EditorGUILayout.LabelField("Put below the UI for the text itself:");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("textUI"));
        if (serializedObject.FindProperty("textUI").objectReferenceValue == null)
        {
            EditorGUILayout.HelpBox("There should be a Text, inside of a Canvas, to show the Talk.", MessageType.Error, true);
        }
        if (rpgTalk.dialoger)
        {
            EditorGUILayout.LabelField("Put below the UI for the name of the talker:");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("dialogerUI"));
            if (serializedObject.FindProperty("dialogerUI").objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("There should be a Text, inside of a Canvas, to show the talker's name.", MessageType.Error, true);
            }
        }
        if (rpgTalk.shouldUsePhotos)
        {
            EditorGUILayout.LabelField("Put below the UI for the photo of the talker:");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("UIPhoto"));
            if (serializedObject.FindProperty("UIPhoto").objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("There should be a Image, inside of a Canvas, to show the talker's photo.", MessageType.Error, true);
            }
        }
        EditorGUILayout.LabelField("An object can blink when expecting player action:");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("blinkWhenReady"), GUIContent.none);
        EditorGUILayout.EndVertical();


        EditorGUILayout.BeginVertical((GUIStyle)"HelpBox");
        EditorGUILayout.LabelField("Callback, Breaks & Variables:", EditorStyles.boldLabel);
        EditorGUILayout.LabelField("Any script should be called when the Talk is done?");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("callbackScript"), GUIContent.none);
        if (serializedObject.FindProperty("callbackScript").objectReferenceValue != null)
        {
            EditorGUILayout.LabelField("What function on that script should be called?");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("callbackFunction"), GUIContent.none);
            if (serializedObject.FindProperty("callbackFunction").stringValue == "")
            {
                EditorGUILayout.HelpBox("You said that a script should be called as callback, but didn't set the name of the functions to be called in that script", MessageType.Error, true);
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("What line of the text should the Talk start? And in what line shoult it end?");
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("lineToStart"), GUIContent.none);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("lineToBreak"), GUIContent.none);
        EditorGUILayout.EndHorizontal();
        if (serializedObject.FindProperty("lineToStart").intValue < 1)
        {
            EditorGUILayout.HelpBox("The line that the Text should start must be 1 or greater!", MessageType.Error, true);
        }
        if (serializedObject.FindProperty("lineToBreak").intValue != -1 &&
            serializedObject.FindProperty("lineToBreak").intValue < serializedObject.FindProperty("lineToStart").intValue)
        {
            EditorGUILayout.HelpBox("The line of the Text to stop the Talk comes before the line of the Text to start the Talk? " +
                                    "That makes no sense! If you want to read the Text file until the end, leave the line to break as '-1'", MessageType.Error, true);
        }

        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Variables can be set to change some word in the text");
        EditorGUI.indentLevel++;
        EditorGUILayout.PropertyField(serializedObject.FindProperty("variables"), true);
        EditorGUI.indentLevel--;

        if (rpgTalk.shouldUsePhotos)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Different photos for different talkers:");
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(serializedObject.FindProperty("photos"), true);
            EditorGUI.indentLevel--;
        }


        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical((GUIStyle)"HelpBox");
        EditorGUILayout.LabelField("Animation:", EditorStyles.boldLabel);
        EditorGUILayout.LabelField("A Animator can be manipulated when talking:");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("animatorWhenTalking"), GUIContent.none);
        if (serializedObject.FindProperty("animatorWhenTalking").objectReferenceValue != null)
        {
            EditorGUILayout.LabelField("A Boolean to be set true when the character is talking:");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("animatorBooleanName"), GUIContent.none);
            EditorGUILayout.LabelField("A int can be set with the number of the talker, based on the list of photos:");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("animatorIntName"), GUIContent.none);

            /*EditorGUILayout.BeginHorizontal();
             * EditorGUILayout.PropertyField (serializedObject.FindProperty("triggerInLineName"),GUIContent.none);
             * EditorGUILayout.PropertyField (serializedObject.FindProperty("triggerInLine"),GUIContent.none);
             * EditorGUILayout.EndHorizontal();
             * if(serializedObject.FindProperty("triggerInLine").intValue < 0){
             *      EditorGUILayout.HelpBox("The line that the Trigger is set must be 0 or positve!", MessageType.Error, true);
             * }*/
        }
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical((GUIStyle)"HelpBox");
        EditorGUILayout.LabelField("Audio:", EditorStyles.boldLabel);
        EditorGUILayout.LabelField("The audio to be played by each letter:");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("textAudio"), GUIContent.none);
        EditorGUILayout.LabelField("The audio to be played when the player passes the Talk:");
        EditorGUILayout.PropertyField(serializedObject.FindProperty("passAudio"), GUIContent.none);
        EditorGUILayout.EndVertical();

        EditorGUILayout.Separator();

        EditorGUILayout.BeginVertical((GUIStyle)"HelpBox");
        EditorGUILayout.LabelField("So, I heard you like free stuff, hum?", EditorStyles.boldLabel);
        GUIStyle style = new GUIStyle();

        style.richText = true;
        string color = "#cc0000";

        GUILayout.Label(string.Format("Be sure to show your support by following <b><color={0}>Seize Studios</color></b> on social medias!", color), style);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Like our page on Facebook!"))
        {
            Application.OpenURL(@"https://www.facebook.com/seizestudios/");
        }
        if (GUILayout.Button("Follow us on Twitter!"))
        {
            Application.OpenURL(@"https://twitter.com/seizestudios");
        }
        EditorGUILayout.EndHorizontal();
        GUIStyle centeredStyle = GUI.skin.GetStyle("Label");

        centeredStyle.alignment = TextAnchor.UpperCenter;
        EditorGUILayout.LabelField("www.seizestudios.com", centeredStyle);
        EditorGUILayout.EndVertical();



        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }
        EditorGUIUtility.LookLikeControls();
    }
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();
        EditorGUI.indentLevel = 1;

        PhotonView mp = (PhotonView)this.target;
        bool       isProjectPrefab = EditorUtility.IsPersistent(mp.gameObject);


        // OWNER
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("Owner:", "Set at runtime");
        }
        else if (mp.isSceneView)
        {
            EditorGUILayout.LabelField("Owner:", "Scene");
        }
        else if (mp.owner == null)
        {
            EditorGUILayout.LabelField("Owner:", "null, disconnected?");
        }
        else
        {
            EditorGUILayout.LabelField("Owner:", "[" + mp.ownerId + "] " + mp.owner);
        }


        // View ID
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("View ID", "Set at runtime");
        }
        else if (EditorApplication.isPlaying)
        {
            if (mp.ownerId != 0 && mp.owner != null)
            {
                EditorGUILayout.LabelField("View ID", "[" + mp.ownerId + "] " + mp.viewID);
            }
            else
            {
                EditorGUILayout.LabelField("View ID", mp.viewID + string.Empty);
            }
        }
        else
        {
            int newId = EditorGUILayout.IntField("View ID [0.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", mp.viewID);
            if (newId != mp.viewID)
            {
                mp.viewID = newId;
                EditorUtility.SetDirty(mp);
                PhotonViewHandler.HierarchyChange();
            }
        }


        // OBSERVING
        EditorGUILayout.BeginHorizontal();

        // Using a lower version then 3.4? Remove the TRUE in the next line to fix an compile error
        string title     = string.Empty;
        int    firstOpen = 0;

        if (mp.observed != null)
        {
            firstOpen = mp.observed.ToString().IndexOf('(');
        }

        if (firstOpen > 0)
        {
            title = mp.observed.ToString().Substring(firstOpen - 1);
        }

        mp.observed = (Component)EditorGUILayout.ObjectField("Observe: " + title, mp.observed, typeof(Component), true);
        if (GUI.changed)
        {
            PhotonViewHandler.HierarchyChange();  // TODO: check if needed
            if (mp.observed != null)
            {
                mp.synchronization = ViewSynchronization.ReliableDeltaCompressed;
            }
            else
            {
                mp.synchronization = ViewSynchronization.Off;
            }
        }

        EditorGUILayout.EndHorizontal();

        if (mp.synchronization == ViewSynchronization.Off)
        {
            GUI.color = Color.grey;
        }

        mp.synchronization = (ViewSynchronization)EditorGUILayout.EnumPopup("Observe option:", mp.synchronization);
        if (GUI.changed)
        {
            PhotonViewHandler.HierarchyChange();  // TODO: check if needed
            if (mp.synchronization != ViewSynchronization.Off && mp.observed == null)
            {
                EditorUtility.DisplayDialog("Warning", "Setting the synchronization option only makes sense if you observe something.", "OK, I will fix it.");
            }
        }

        if (mp.observed != null)
        {
            Type type = mp.observed.GetType();
            if (type == typeof(Transform))
            {
                mp.onSerializeTransformOption = (OnSerializeTransform)EditorGUILayout.EnumPopup("Serialization:", mp.onSerializeTransformOption);
            }
            else if (type == typeof(Rigidbody))
            {
                mp.onSerializeRigidBodyOption = (OnSerializeRigidBody)EditorGUILayout.EnumPopup("Serialization:", mp.onSerializeRigidBodyOption);
            }
        }

        GUI.color = Color.white;
        EditorGUIUtility.LookLikeControls();
    }
    public void OnGUI()
    {
        EditorGUIUtility.LookLikeInspector();

        DisplaySetup();
    }
    public override void OnInspectorGUI()
    {
        spriteUiVisible = EditorGUILayout.Foldout(spriteUiVisible, "Sprite");
        if (spriteUiVisible)
        {
            base.OnInspectorGUI();
        }

        Init();
        if (animLibs == null)
        {
            GUILayout.Label("no libraries found");
            if (GUILayout.Button("Refresh"))
            {
                initialized = false;
                Init();
            }
        }
        else
        {
            tk2dAnimatedSprite sprite = (tk2dAnimatedSprite)target;

            EditorGUIUtility.LookLikeInspector();
            EditorGUI.indentLevel = 1;

            if (sprite.anim == null)
            {
                sprite.anim = animLibs[0];
                GUI.changed = true;
            }

            // Display animation library
            int selAnimLib = 0;
            for (int i = 0; i < animLibs.Length; ++i)
            {
                if (animLibs[i] == sprite.anim)
                {
                    selAnimLib = i;
                    break;
                }
            }

            int newAnimLib = EditorGUILayout.Popup("Anim Lib", selAnimLib, animLibNames);
            if (newAnimLib != selAnimLib)
            {
                sprite.anim   = animLibs[newAnimLib];
                sprite.clipId = 0;

                if (sprite.anim.clips.Length > 0)
                {
                    // automatically switch to the first frame of the new clip
                    sprite.SwitchCollectionAndSprite(sprite.anim.clips[sprite.clipId].frames[0].spriteCollection,
                                                     sprite.anim.clips[sprite.clipId].frames[0].spriteId);
                }
            }

            // Everything else
            if (sprite.anim && sprite.anim.clips.Length > 0)
            {
                int clipId = sprite.clipId;

                // Sanity check clip id
                clipId = Mathf.Clamp(clipId, 0, sprite.anim.clips.Length - 1);
                if (clipId != sprite.clipId)
                {
                    sprite.clipId = clipId;
                    GUI.changed   = true;
                }

                string[] clipNames = new string[sprite.anim.clips.Length];
                for (int i = 0; i < sprite.anim.clips.Length; ++i)
                {
                    clipNames[i] = sprite.anim.clips[i].name;
                }
                int newClipId = EditorGUILayout.Popup("Clip", sprite.clipId, clipNames);
                if (newClipId != sprite.clipId)
                {
                    sprite.clipId = newClipId;
                    // automatically switch to the first frame of the new clip
                    sprite.SwitchCollectionAndSprite(sprite.anim.clips[sprite.clipId].frames[0].spriteCollection,
                                                     sprite.anim.clips[sprite.clipId].frames[0].spriteId);
                }
            }

            // Play automatically
            sprite.playAutomatically = EditorGUILayout.Toggle("Play automatically", sprite.playAutomatically);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(sprite);
            }
        }
    }
    /// editor OnInspectorGUI to control the NIEventLogger properties
    override public void OnInspectorGUI()
    {
        EditorGUI.indentLevel = 0;
        EditorGUIUtility.LookLikeInspector();
        NISkeletonController controller = target as NISkeletonController;

        EditorGUILayout.LabelField("Controlling player", "");
        EditorGUI.indentLevel     += 2;
        controller.m_playerManager = EditorGUILayout.ObjectField("Player manager", controller.m_playerManager, typeof(NIPlayerManager), true) as NIPlayerManager;
        controller.m_playerNumber  = EditorGUILayout.IntField("Player Number", controller.m_playerNumber);
        EditorGUI.indentLevel     -= 2;
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Joints to control", "");
        EditorGUI.indentLevel += 2;
        // make sure the joint transforms are initialized.
        if (controller.m_jointTransforms == null)
        {
            controller.m_jointTransforms = new Transform[Enum.GetNames(typeof(SkeletonJoint)).Length + 1];
            for (int i = 0; i < controller.m_jointTransforms.Length; i++)
            {
                controller.m_jointTransforms[i] = null;
            }
        }
        else if (controller.m_jointTransforms.Length != Enum.GetNames(typeof(SkeletonJoint)).Length + 1)
        {
            // the skeleton joints enum changed since last time...
            Transform[] newVal = new Transform[Enum.GetNames(typeof(SkeletonJoint)).Length + 1];
            for (int i = 0; i < newVal.Length; i++)
            {
                if (i < controller.m_jointTransforms.Length)
                {
                    newVal[i] = controller.m_jointTransforms[i];
                }
                else
                {
                    newVal[i] = null;
                }
            }
            controller.m_jointTransforms = newVal;
        }
        foreach (SkeletonJoint joint in Enum.GetValues(typeof(SkeletonJoint)))
        {
            controller.m_jointTransforms[(int)joint] = EditorGUILayout.ObjectField("" + joint, controller.m_jointTransforms[(int)joint], typeof(Transform), true) as Transform;
        }
        EditorGUI.indentLevel -= 2;
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("What to update", "");
        EditorGUI.indentLevel            += 2;
        controller.m_updateRootPosition   = EditorGUILayout.Toggle("Update Root Positions?", controller.m_updateRootPosition);
        controller.m_updateJointPositions = EditorGUILayout.Toggle("Update Joint Positions?", controller.m_updateJointPositions);
        controller.m_updateOrientation    = EditorGUILayout.Toggle("Update joint Orientation?", controller.m_updateOrientation);
        EditorGUI.indentLevel            -= 2;
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Scaling & limitations", "");
        EditorGUI.indentLevel         += 2;
        controller.m_rotationDampening = EditorGUILayout.FloatField("Rotation Dampening", controller.m_rotationDampening);
        controller.m_scale             = EditorGUILayout.FloatField("Scale", controller.m_scale);
        controller.m_speed             = EditorGUILayout.FloatField("Torso speed scale", controller.m_speed);
        EditorGUI.indentLevel         -= 2;

        EditorGUILayout.Space();
        controller.m_linesDebugger = EditorGUILayout.ObjectField("Lines debugger", controller.m_linesDebugger, typeof(NISkeletonControllerLineDebugger), true) as NISkeletonControllerLineDebugger;

        EditorGUILayout.Space();

        EditorGUI.indentLevel -= 2;
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* Redefined Method: OnInspectorGUI
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();

        EditorGUILayout.Space();
        Target.m_DialogueBoxScript = EditorGUILayout.ObjectField("Dialogue Box Script: ", Target.m_DialogueBoxScript, typeof(DialogueBox), true) as DialogueBox;

        EditorGUILayout.Space();
        Target.m_DialogueBoxScrollSpeed = EditorGUILayout.FloatField("Dialogue Box Scroll Speed: ", Target.m_DialogueBoxScrollSpeed);

        EditorGUIUtility.LookLikeControls();
        EditorGUILayout.Space();
        Target.m_Speaker = (DialogueBox.SpokesPersonState)EditorGUILayout.EnumPopup("Starting Speaker: ", Target.m_Speaker);

        EditorGUILayout.Space();
        GUILayout.Label("Text");
        Target.m_sNewText = EditorGUILayout.TextArea(Target.m_sNewText, GUILayout.MaxHeight(150));


        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("End Current Text Block", EditorStyles.boldLabel);
        EditorGUI.indentLevel += 1;
        {
            EditorGUILayout.TextField("Command: ", "\\endl");
        }
        EditorGUI.indentLevel -= 1;


        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Text Colour", EditorStyles.boldLabel);
        EditorGUI.indentLevel += 1;
        {
            m_Colour = EditorGUILayout.ColorField("Colour: ", m_Colour);
            EditorGUILayout.TextField("Colour Command: ", GetColourCommand());
            EditorGUILayout.TextField("Revert Command: ", "[-]");
        }
        EditorGUI.indentLevel -= 1;


        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Change Speaker", EditorStyles.boldLabel);
        EditorGUI.indentLevel += 1;
        {
            m_eNextSpeaker = (DialogueBox.SpokesPersonState)EditorGUILayout.EnumPopup("New Speaker: ", m_eNextSpeaker);
            EditorGUILayout.TextField("Command: ", GetNextSpeakerCommand());
        }
        EditorGUI.indentLevel -= 1;



        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Pause Game", EditorStyles.boldLabel);
        EditorGUI.indentLevel += 1;
        {
            EditorGUILayout.TextField("Command: ", "\\<PAUSE>");

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Conditions:", EditorStyles.boldLabel);

            EditorGUI.indentLevel += 1;
            {
                // Modify Array	::	Code By: Darclaw	~  http://answers.unity3d.com/questions/26207/how-can-i-recreate-the-array-inspector-element-for.html#answer-220601
                SerializedProperty PauseKeys = serializedObject.FindProperty("m_PauseKeys");
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(PauseKeys, true);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }

                EditorGUILayout.Space();
                // Modify Array	::	Code By: Darclaw	~  http://answers.unity3d.com/questions/26207/how-can-i-recreate-the-array-inspector-element-for.html#answer-220601
                SerializedProperty PauseAxis = serializedObject.FindProperty("m_PauseAxis");
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(PauseAxis, true);
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
            EditorGUI.indentLevel -= 1;
        }
        EditorGUI.indentLevel -= 1;



        if (GUI.changed)
        {
            EditorUtility.SetDirty(Target);
            this.Repaint();
        }
    }
Exemplo n.º 12
0
    // Lets the user choose a Multi Target from a drop down list. Multi Target
    // must be defined in the "config.xml" file.
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeInspector();

        DrawDefaultInspector();

        MultiTargetBehaviour        mtb       = (MultiTargetBehaviour)target;
        IEditorMultiTargetBehaviour editorMtb = mtb;

        if (QCARUtilities.GetPrefabType(mtb) ==
            PrefabType.Prefab)
        {
            GUILayout.Label("You can't choose a target for a prefab.");
        }
        else if (ConfigDataManager.Instance.NumConfigDataObjects > 1)
        {
            // Draw list for choosing a data set.
            string[] dataSetList = new string[ConfigDataManager.Instance.NumConfigDataObjects];
            ConfigDataManager.Instance.GetConfigDataNames(dataSetList);
            int currentDataSetIndex =
                QCARUtilities.GetIndexFromString(editorMtb.DataSetName, dataSetList);

            // If name is not in array we automatically choose default name;
            if (currentDataSetIndex < 0)
            {
                currentDataSetIndex = 0;
            }

            int newDataSetIndex = EditorGUILayout.Popup("Data Set",
                                                        currentDataSetIndex,
                                                        dataSetList);

            string chosenDataSet = dataSetList[newDataSetIndex];

            ConfigData dataSetData = ConfigDataManager.Instance.GetConfigData(chosenDataSet);

            // Draw list for choosing a Trackable.
            string[] namesList = new string[dataSetData.NumMultiTargets];
            dataSetData.CopyMultiTargetNames(namesList, 0);
            int currentTrackableIndex =
                QCARUtilities.GetIndexFromString(editorMtb.TrackableName, namesList);

            // If name is not in array we automatically choose default name;
            if (currentTrackableIndex < 0)
            {
                currentTrackableIndex = 0;
            }

            int newTrackableIndex = EditorGUILayout.Popup("Multi Target",
                                                          currentTrackableIndex,
                                                          namesList);

            if (namesList.Length > 0)
            {
                if (newDataSetIndex != currentDataSetIndex || newTrackableIndex != currentTrackableIndex)
                {
                    editorMtb.SetDataSetPath("QCAR/" + dataSetList[newDataSetIndex] + ".xml");

                    editorMtb.SetNameForTrackable(namesList[newTrackableIndex]);
                }
            }
        }
        else
        {
            if (GUILayout.Button("No targets defined. Press here for target " +
                                 "creation!"))
            {
                SceneManager.Instance.GoToARPage();
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(mtb);

            // If name has changed we apply the correct values from the config
            // file.
            TrackableAccessor accessor = AccessorFactory.Create(mtb);
            if (accessor != null)
            {
                accessor.ApplyDataSetProperties();
            }

            SceneManager.Instance.SceneUpdated();
        }
    }
        public override void OnInspectorGUI()
        {
            Transform t = (Transform)target;

            // Replicate the standard transform inspector gui
            EditorGUIUtility.LookLikeControls();
            EditorGUI.indentLevel = 0;


            //	Position
            EditorGUILayout.BeginHorizontal();
            //	reset
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                t.localPosition = Vector3.zero;
            }
            //	label
            GUILayout.Label("Position", GUILayout.Width(100));
            //	values
            Vector3 position = EditorGUILayout.Vector3Field(new GUIContent(), t.localPosition);

            EditorGUILayout.EndHorizontal();

            //	Rotation
            EditorGUILayout.BeginHorizontal();
            //	reset
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                t.localEulerAngles = Vector3.zero;
            }
            //	label
            GUILayout.Label("Rotation", GUILayout.Width(100));
            //	values
            Vector3 eulerAngles = EditorGUILayout.Vector3Field(new GUIContent(), t.localEulerAngles);

            EditorGUILayout.EndHorizontal();

            //	Scale
            EditorGUILayout.BeginHorizontal();
            //	reset
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                t.localScale = new Vector3(1, 1, 1);
            }
            //	label
            GUILayout.Label("Scale", GUILayout.Width(100));
            //	values
            Vector3 scale = EditorGUILayout.Vector3Field(new GUIContent(), t.localScale);

            EditorGUILayout.EndHorizontal();


            EditorGUIUtility.LookLikeInspector();

            if (GUI.changed)
            {
                Undo.RegisterUndo(t, "Transform Change");

                t.localPosition    = FixIfNaN(position);
                t.localEulerAngles = FixIfNaN(eulerAngles);
                t.localScale       = FixIfNaN(scale);
            }
        }
    public override void OnInspectorGUI()
    {
        Transform t = (Transform)target;

        // Replicate the standard transform inspector gui
        EditorGUIUtility.LookLikeControls();
        EditorGUI.indentLevel = 0;
        Vector3 position    = EditorGUILayout.Vector3Field("Position", t.localPosition);
        Vector3 eulerAngles = EditorGUILayout.Vector3Field("Rotation", t.localEulerAngles);
        Vector3 scale       = EditorGUILayout.Vector3Field("Scale", t.localScale);

        EditorGUIUtility.LookLikeInspector();

        //
        if (GUILayout.Button((showTools) ? "Hide Transform Tools" : "Show Transform Tools"))
        {
            showTools = !showTools;
            EditorPrefs.SetBool("ShowTools", showTools);
        }
        //  START TRANSFORM TOOLS FOLD DOWN //
        if (showTools)
        {
            if (!copyPosition && !copyRotation && !copyScale)
            {
                selectionNullError = true;
            }
            else
            {
                selectionNullError = false;
            }
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(selectionNullError ? "Nothing Selected" : "Copy Transform"))
            {
                if (copyPosition)
                {
                    EditorPrefs.SetFloat("LocalPosX", t.localPosition.x);
                    EditorPrefs.SetFloat("LocalPosY", t.localPosition.y);
                    EditorPrefs.SetFloat("LocalPosZ", t.localPosition.z);
                }
                if (copyRotation)
                {
                    EditorPrefs.SetFloat("LocalRotX", t.localEulerAngles.x);
                    EditorPrefs.SetFloat("LocalRotY", t.localEulerAngles.y);
                    EditorPrefs.SetFloat("LocalRotZ", t.localEulerAngles.z);
                }
                if (copyScale)
                {
                    EditorPrefs.SetFloat("LocalScaleX", t.localScale.x);
                    EditorPrefs.SetFloat("LocalScaleY", t.localScale.y);
                    EditorPrefs.SetFloat("LocalScaleZ", t.localScale.z);
                }

                Debug.Log("LP: " + t.localPosition + " LT: (" + t.localEulerAngles.x + ", " + t.localEulerAngles.y + ", " + t.localEulerAngles.z + ") LS: " + t.localScale);
            }
            if (GUILayout.Button("Paste Transform"))
            {
                Vector3 tV3 = new Vector3();
                if (pastePosition)
                {
                    tV3.x           = EditorPrefs.GetFloat("LocalPosX", 0.0f);
                    tV3.y           = EditorPrefs.GetFloat("LocalPosY", 0.0f);
                    tV3.z           = EditorPrefs.GetFloat("LocalPosZ", 0.0f);
                    t.localPosition = tV3;
                }
                if (pasteRotation)
                {
                    tV3.x = EditorPrefs.GetFloat("LocalRotX", 0.0f);
                    tV3.y = EditorPrefs.GetFloat("LocalRotY", 0.0f);
                    tV3.z = EditorPrefs.GetFloat("LocalRotZ", 0.0f);
                    t.localEulerAngles = tV3;
                }
                if (pasteScale)
                {
                    tV3.x        = EditorPrefs.GetFloat("LocalScaleX", 1.0f);
                    tV3.y        = EditorPrefs.GetFloat("LocalScaleY", 1.0f);
                    tV3.z        = EditorPrefs.GetFloat("LocalScaleZ", 1.0f);
                    t.localScale = tV3;
                }

                Debug.Log("LP: " + t.localPosition + " LT: " + t.localEulerAngles + " LS: " + t.localScale);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUIUtility.LookLikeControls();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Position", GUILayout.Width(75));
            GUILayout.Label("Rotation", GUILayout.Width(75));
            GUILayout.Label("Scale", GUILayout.Width(50));
            if (GUILayout.Button("All", GUILayout.MaxWidth(40)))
            {
                TransformCopyAll();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(20);
            copyPosition = EditorGUILayout.Toggle(copyPosition, GUILayout.Width(75));
            copyRotation = EditorGUILayout.Toggle(copyRotation, GUILayout.Width(65));
            copyScale    = EditorGUILayout.Toggle(copyScale, GUILayout.Width(45));
            if (GUILayout.Button("None", GUILayout.MaxWidth(40)))
            {
                TransformCopyNone();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUIUtility.LookLikeInspector();
        }
        //  END TRANSFORM TOOLS FOLD DOWN   //

        if (GUI.changed)
        {
            SetCopyPasteBools();
            Undo.RegisterUndo(t, "Transform Change");

            t.localPosition    = FixIfNaN(position);
            t.localEulerAngles = FixIfNaN(eulerAngles);
            t.localScale       = FixIfNaN(scale);
        }
    }
Exemplo n.º 15
0
        public override void OnInspectorGUI()
        {
            if (!_isAssimpAsset)
            {
                base.OnInspectorGUI();
                return;
            }
            GUI.enabled = true;
#pragma warning disable 618
            EditorGUIUtility.LookLikeInspector();
#pragma warning restore 618
            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
            _currentTab = GUILayout.Toggle(_currentTab == 0, "General", "Button") ? 0 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 1, "Meshes", "Button") ? 1 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 2, "Materials", "Button") ? 2 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 3, "Animations", "Button") ? 3 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 4, "Misc", "Button") ? 4 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 5, "Metadata", "Button") ? 5 : _currentTab;
            _currentTab = GUILayout.Toggle(_currentTab == 6, "Advanced", "Button") ? 6 : _currentTab;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            switch (_currentTab)
            {
            case 0:
                EditorGUILayout.LabelField("General", EditorStyles.boldLabel);
#if UNITY_2017_3_OR_NEWER
                _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumFlagsField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps);
#else
                _tempAssetLoaderOptions.PostProcessSteps = (AssimpPostProcessSteps)EditorGUILayout.EnumMaskField("Post Processor Options", _tempAssetLoaderOptions.PostProcessSteps);
#endif
                break;

            case 1:
            {
                EditorGUILayout.LabelField("Meshes", EditorStyles.boldLabel);
                var dontLoadMeshesProperty = _tempSerializedObject.FindProperty("DontLoadMeshes");
                EditorGUILayout.PropertyField(dontLoadMeshesProperty);
                if (!dontLoadMeshesProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("CombineMeshes"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Scale"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("RotationAngles"));
#if UNITY_2017_3_OR_NEWER
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("Use32BitsIndexFormat"));
#endif
                    var generateMeshCollidersProperty = _tempSerializedObject.FindProperty("GenerateMeshColliders");
                    EditorGUILayout.PropertyField(generateMeshCollidersProperty);
                    if (generateMeshCollidersProperty.boolValue)
                    {
                        EditorGUI.indentLevel = 1;
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ConvexMeshColliders"));
                        EditorGUI.indentLevel = 0;
                    }
                }
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadSkinning"));
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadBlendShapes"));
            }
            break;

            case 2:
            {
                EditorGUILayout.LabelField("Materials", EditorStyles.boldLabel);
                var dontLoadMaterialsProperty = _tempSerializedObject.FindProperty("DontLoadMaterials");
                EditorGUILayout.PropertyField(dontLoadMaterialsProperty);
                if (!dontLoadMaterialsProperty.boolValue)
                {
                    var disableAlphaMaterials = _tempSerializedObject.FindProperty("DisableAlphaMaterials");
                    EditorGUILayout.PropertyField(disableAlphaMaterials);
                    if (!disableAlphaMaterials.boolValue)
                    {
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyColorAlpha"));
                    }
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDiffuseColor"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyEmissionColor"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplySpecularColor"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDiffuseTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyEmissionTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplySpecularTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyNormalTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyDisplacementTexture"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyNormalScale"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyGlossiness"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ApplyGlossinessScale"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("GenerateMipMaps"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("UseStandardSpecularMaterial"));
                    if (!disableAlphaMaterials.boolValue)
                    {
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("ScanForAlphaMaterials"));
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("UseCutoutMaterials"));
                    }
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TextureCompression"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("TextureFilterMode"));
                }
            }
            break;

            case 3:
            {
                EditorGUILayout.LabelField("Animations", EditorStyles.boldLabel);
                var dontLoadAnimationsProperty = _tempSerializedObject.FindProperty("DontLoadAnimations");
                EditorGUILayout.PropertyField(dontLoadAnimationsProperty);
                if (!dontLoadAnimationsProperty.boolValue)
                {
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AutoPlayAnimations"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimationWrapMode"));
                    EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("EnsureQuaternionContinuity"));
                    var legacyAnimationProperty = _tempSerializedObject.FindProperty("UseLegacyAnimations");
                    EditorGUILayout.PropertyField(legacyAnimationProperty);
                    if (!legacyAnimationProperty.boolValue)
                    {
                        EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AnimatorController"));
                        var avatar = _tempSerializedObject.FindProperty("Avatar");
                        EditorGUILayout.PropertyField(avatar);
                        if (avatar.objectReferenceValue == null)
                        {
                            EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontGenerateAvatar"));
                        }
                    }
                }
            }
            break;

            case 4:
            {
                EditorGUILayout.LabelField("Misc", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("AddAssetUnloader"));
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadCameras"));
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadLights"));
            }
            break;

            case 5:
            {
                EditorGUILayout.LabelField("Metadata", EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(_tempSerializedObject.FindProperty("DontLoadMetadata"));
            }
            break;

            default:
            {
                EditorGUILayout.LabelField("Advanced", EditorStyles.boldLabel);
                var advancedConfigs = _tempSerializedObject.FindProperty("AdvancedConfigs");
                var lastGroup       = string.Empty;
                var groupIndex      = 0;
                foreach (var configKey in AssetAdvancedPropertyMetadata.ConfigKeys)
                {
                    AssetAdvancedConfigType assetAdvancedConfigType;
                    string className;
                    string description;
                    string group;
                    bool   hasDefaultValue;
                    bool   hasMinValue;
                    bool   hasMaxValue;
                    object defaultValue;
                    object minValue;
                    object maxValue;
                    AssetAdvancedPropertyMetadata.GetOptionMetadata(configKey, out assetAdvancedConfigType, out className, out description, out group, out defaultValue, out minValue, out maxValue, out hasDefaultValue, out hasMinValue, out hasMaxValue);
                    SerializedProperty elementSerializedProperty = null;
                    var serializedElementIndex = 0;
                    var recentlyCreated        = false;
                    for (var i = 0; i < _tempAssetLoaderOptions.AdvancedConfigs.Count; i++)
                    {
                        var advancedProperty = _tempAssetLoaderOptions.AdvancedConfigs[i];
                        if (advancedProperty.Key == configKey)
                        {
                            serializedElementIndex    = i;
                            elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(i);
                            break;
                        }
                    }
                    if (group != lastGroup)
                    {
                        lastGroup = group;
                        _groupUnfolded[groupIndex] = EditorGUILayout.Foldout(_groupUnfolded[groupIndex], lastGroup);
                        groupIndex++;
                    }
                    if (_groupUnfolded[groupIndex - 1])
                    {
                        EditorGUILayout.BeginHorizontal();
                        var enableProperty = EditorGUILayout.BeginToggleGroup(new GUIContent(className, description), elementSerializedProperty != null);
                        if (elementSerializedProperty == null && enableProperty)
                        {
                            advancedConfigs.InsertArrayElementAtIndex(advancedConfigs.arraySize);
                            _tempSerializedObject.ApplyModifiedProperties();
                            var elementIndex = Mathf.Max(0, advancedConfigs.arraySize - 1);
                            elementSerializedProperty = advancedConfigs.GetArrayElementAtIndex(elementIndex);
                            elementSerializedProperty.FindPropertyRelative("Key").stringValue = configKey;
                            _tempSerializedObject.ApplyModifiedProperties();
                            recentlyCreated = true;
                        }
                        else if (elementSerializedProperty != null && !enableProperty)
                        {
                            advancedConfigs.DeleteArrayElementAtIndex(serializedElementIndex);
                            _tempSerializedObject.ApplyModifiedProperties();
                            return;
                        }
                        SerializedProperty valueSerializedProperty;
                        switch (assetAdvancedConfigType)
                        {
                        case AssetAdvancedConfigType.Bool:
                            var boolDefaultValue = hasDefaultValue && (bool)defaultValue;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.Toggle(boolDefaultValue ? "Enabled" : "Disabled", boolDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("BoolValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.boolValue = boolDefaultValue;
                                }
                                EditorGUILayout.PropertyField(valueSerializedProperty, new GUIContent(valueSerializedProperty.boolValue ? "Enabled" : "Disabled"));
                            }
                            break;

                        case AssetAdvancedConfigType.Integer:
                            var intDefaultValue = hasDefaultValue ? (int)defaultValue : 0;
                            if (hasMinValue && hasMaxValue)
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.IntSlider(intDefaultValue, (int)minValue, (int)maxValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.intValue = intDefaultValue;
                                    }
                                    EditorGUILayout.IntSlider(valueSerializedProperty, (int)minValue, (int)maxValue, GUIContent.none);
                                }
                            }
                            else
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.IntField(intDefaultValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.intValue = intDefaultValue;
                                    }
                                    EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                                }
                            }
                            break;

                        case AssetAdvancedConfigType.Float:
                            var floatDefaultValue = hasDefaultValue ? (float)defaultValue : 0f;
                            if (hasMinValue && hasMaxValue)
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.Slider(floatDefaultValue, (float)minValue, (float)maxValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.floatValue = floatDefaultValue;
                                    }
                                    EditorGUILayout.Slider(valueSerializedProperty, (float)minValue, (float)maxValue, GUIContent.none);
                                }
                            }
                            else
                            {
                                if (elementSerializedProperty == null)
                                {
                                    GUI.enabled = false;
                                    EditorGUILayout.FloatField(floatDefaultValue);
                                }
                                else
                                {
                                    GUI.enabled             = true;
                                    valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("FloatValue");
                                    if (recentlyCreated)
                                    {
                                        valueSerializedProperty.floatValue = floatDefaultValue;
                                    }
                                    EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                                }
                            }
                            break;

                        case AssetAdvancedConfigType.String:
                            var stringDefaultValue = hasDefaultValue ? (string)defaultValue : string.Empty;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                EditorGUILayout.TextField(stringDefaultValue);
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("StringValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.stringValue = stringDefaultValue;
                                }
                                EditorGUILayout.PropertyField(valueSerializedProperty, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiComponent:
                            var aiComponentDefaultValue = hasDefaultValue ? (AiComponent)defaultValue : AiComponent.Animations;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
#if UNITY_2017_3_OR_NEWER
                                EditorGUILayout.EnumFlagsField(aiComponentDefaultValue);
#else
                                EditorGUILayout.EnumMaskField(aiComponentDefaultValue);
#endif
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiComponentDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiPrimitiveType:
                            var aiPrimitiveTypeDefaultValue = hasDefaultValue ? (AiPrimitiveType)defaultValue : AiPrimitiveType.Line;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
#if UNITY_2017_3_OR_NEWER
                                EditorGUILayout.EnumFlagsField(aiPrimitiveTypeDefaultValue);
#else
                                EditorGUILayout.EnumMaskField(aiPrimitiveTypeDefaultValue);
#endif
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiPrimitiveTypeDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiUVTransform:
                            var aiUvTransformDefaultValue = hasDefaultValue ? (AiUVTransform)defaultValue : AiUVTransform.Rotation;
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
#if UNITY_2017_3_OR_NEWER
                                EditorGUILayout.EnumFlagsField(aiUvTransformDefaultValue);
#else
                                EditorGUILayout.EnumMaskField(aiUvTransformDefaultValue);
#endif
                            }
                            else
                            {
                                GUI.enabled             = true;
                                valueSerializedProperty = elementSerializedProperty.FindPropertyRelative("IntValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty.intValue = (int)aiUvTransformDefaultValue;
                                }
                                PropertyEnumMaskField(valueSerializedProperty, assetAdvancedConfigType, GUIContent.none);
                            }
                            break;

                        case AssetAdvancedConfigType.AiMatrix:
                            if (elementSerializedProperty == null)
                            {
                                GUI.enabled = false;
                                GUILayout.BeginVertical();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Translation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.zero);
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Rotation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.zero);
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Scale", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.Vector3Field(GUIContent.none, Vector3.one);
                                GUILayout.EndHorizontal();
                                GUILayout.EndVertical();
                            }
                            else
                            {
                                GUI.enabled = true;
                                var valueSerializedProperty1 = elementSerializedProperty.FindPropertyRelative("TranslationValue");
                                var valueSerializedProperty2 = elementSerializedProperty.FindPropertyRelative("RotationValue");
                                var valueSerializedProperty3 = elementSerializedProperty.FindPropertyRelative("ScaleValue");
                                if (recentlyCreated)
                                {
                                    valueSerializedProperty1.vector3Value = Vector3.zero;
                                    valueSerializedProperty2.vector3Value = Vector3.zero;
                                    valueSerializedProperty3.vector3Value = Vector3.one;
                                }
                                GUILayout.BeginVertical();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Translation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty1, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Rotation", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty2, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.BeginHorizontal();
                                GUILayout.Label("Scale", GUILayout.Width(75));
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.PropertyField(valueSerializedProperty3, GUIContent.none, true, GUILayout.MinWidth(100));
                                GUILayout.EndHorizontal();
                                GUILayout.EndVertical();
                            }
                            break;
                        }
                        GUI.enabled = true;
                        EditorGUILayout.EndToggleGroup();
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            break;
            }
            if (EditorGUI.EndChangeCheck())
            {
                _hasChanged = true;
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = _hasChanged;
            if (GUILayout.Button("Revert"))
            {
                DestroyTempObject();
                _tempAssetLoaderOptions = AssetLoaderOptions.CreateInstance();
                SaveChanges();
            }
            if (GUILayout.Button("Apply"))
            {
                _tempSerializedObject.ApplyModifiedProperties();
                SaveChanges();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
    public void OnGUI()
    {
        if (detectedBundlesFileInfos == null || detectedBundles == null)
        {
            Refresh();
            return;
        }
        EditorGUIUtility.LookLikeInspector();
        GUILayout.BeginHorizontal();
        GUILayout.Label("Bundles", EditorStyles.boldLabel);
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Refresh", EditorStyles.miniButton))
        {
            Refresh();
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginVertical(GUI.skin.box);
        GUILayout.BeginHorizontal(EditorStyles.toolbar);
        GUILayout.Label("Name", GUILayout.MinWidth(100));
        GUILayout.FlexibleSpace();
        foreach (var plat in AssetBundleListingEditor.Settings.platforms)
        {
            GUILayout.Label(new GUIContent(plat.name, plat.icon32), GUILayout.Height(14), GUILayout.Width(60));
        }
        GUILayout.EndHorizontal();

        List <AssetBundleListing> listingsOutOfDate = new List <AssetBundleListing>();
        var curPlats = AssetBundleListingEditor.Settings.GetPlatformsForCurrentBuildTarget(EditorUserBuildSettings.activeBuildTarget);

        for (int i = 0; i < detectedBundles.Count; i++)
        {
            AssetBundleListing listing = detectedBundles[i];
            if (listing == null)
            {
                Refresh();
                return;
            }
            FileInfo listingFile = detectedBundlesFileInfos[i];
            if (listingFile == null)
            {
                Refresh();
                return;
            }
            Dictionary <string, bool> isOutofdate = new Dictionary <string, bool>();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(listing.name, EditorStyles.miniButton, GUILayout.MinWidth(100)))
            {
                Selection.activeObject = listing;
                EditorGUIUtility.PingObject(Selection.activeObject);
            }
            GUILayout.FlexibleSpace();
            DateTime badDate = new DateTime((System.Int64) 0);
            foreach (var plat in AssetBundleListingEditor.Settings.platforms)
            {
                DateTime lastBundleWriteTime = AssetBundleListingEditor.Settings.GetLastWriteTime(listing, plat.name);
                bool     exists = lastBundleWriteTime != badDate;
                isOutofdate[plat.name] = listingFile.LastWriteTimeUtc > lastBundleWriteTime;
                var platObjs = listing.GetListingForPlatform(plat.name);

                string[] strings = platObjs.ConvertAll <string>((x) => {
                    return(AssetDatabase.GetAssetPath(x));
                }).Distinct().ToArray <string>();
                strings = AssetDatabase.GetDependencies(strings);

                platObjs = Array.ConvertAll <string, UnityEngine.Object>(strings, (x) => {
                    return(AssetDatabase.LoadMainAssetAtPath(x));
                }).ToList();

                foreach (var obj in platObjs)
                {
                    string projectPath = AssetDatabase.GetAssetPath(obj);
                    if (projectPath == "")
                    {
                        continue;
                    }
                    FileInfo objFileInfo  = new FileInfo(projectPath);
                    string   metaPath     = AssetDatabase.GetTextMetaDataPathFromAssetPath(projectPath);
                    FileInfo metaFileInfo = new FileInfo(metaPath);
                    if (objFileInfo.LastWriteTimeUtc > lastBundleWriteTime ||
                        (metaPath != "" && metaFileInfo.LastWriteTimeUtc > lastBundleWriteTime))
                    {
                        isOutofdate[plat.name] = true;
                    }
                }
                if (!exists)
                {
                    GUILayout.Label(AssetBundleListingEditor.Settings.box, GUILayout.Width(60));
                    if (curPlats.Contains(plat) && !listingsOutOfDate.Contains(listing))
                    {
                        listingsOutOfDate.Add(listing);
                    }
                }
                else if (isOutofdate[plat.name])
                {
                    GUILayout.Label(AssetBundleListingEditor.Settings.outOfDate, GUILayout.Width(60));
                    if (curPlats.Contains(plat) && !listingsOutOfDate.Contains(listing))
                    {
                        listingsOutOfDate.Add(listing);
                    }
                }
                else
                {
                    GUILayout.Label(AssetBundleListingEditor.Settings.checkedBox, GUILayout.Width(60));
                }
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndVertical();

        string platList = "";

        foreach (var plat in curPlats)
        {
            platList += " " + plat.name;
        }
        if (listingsOutOfDate.Count > 0 && GUILayout.Button("Build missing/out of date bundles for" + platList + " (" + listingsOutOfDate.Count + ")"))
        {
            foreach (AssetBundleListing listing in listingsOutOfDate)
            {
                AssetBundleListingEditor.BuildBundleForCurrentPlatforms(listing);
            }
        }
    }
Exemplo n.º 17
0
    public override void OnInspectorGUI()
    {
        Init();
        if (animLibs == null)
        {
            GUILayout.Label("no libraries found");
            if (GUILayout.Button("Refresh"))
            {
                initialized = false;
                Init();
            }
        }
        else
        {
            tk2dSpriteAnimator sprite = (tk2dSpriteAnimator)target;

            EditorGUIUtility.LookLikeInspector();
            EditorGUI.indentLevel = 1;

            if (sprite.Library == null)
            {
                sprite.Library = animLibs[0].GetAsset <tk2dSpriteAnimation>();
                GUI.changed    = true;
            }

            // Display animation library
            int    selAnimLib   = 0;
            string selectedGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(sprite.Library));
            for (int i = 0; i < animLibs.Length; ++i)
            {
                if (animLibs[i].assetGUID == selectedGUID)
                {
                    selAnimLib = i;
                    break;
                }
            }

            int newAnimLib = EditorGUILayout.Popup("Anim Lib", selAnimLib, animLibNames);
            if (newAnimLib != selAnimLib)
            {
                Undo.RegisterUndo(targetAnimators, "Sprite Anim Lib");
                foreach (tk2dSpriteAnimator animator in targetAnimators)
                {
                    animator.Library       = animLibs[newAnimLib].GetAsset <tk2dSpriteAnimation>();
                    animator.DefaultClipId = 0;

                    if (animator.Library.clips.Length > 0)
                    {
                        if (animator.Sprite != null)
                        {
                            // automatically switch to the first frame of the new clip
                            animator.Sprite.SetSprite(animator.Library.clips[animator.DefaultClipId].frames[0].spriteCollection,
                                                      animator.Library.clips[animator.DefaultClipId].frames[0].spriteId);
                        }
                    }
                }
            }

            // Everything else
            if (sprite.Library && sprite.Library.clips.Length > 0)
            {
                int clipId = sprite.DefaultClipId;

                // Sanity check clip id
                clipId = Mathf.Clamp(clipId, 0, sprite.Library.clips.Length - 1);
                if (clipId != sprite.DefaultClipId)
                {
                    sprite.DefaultClipId = clipId;
                    GUI.changed          = true;
                }

                List <string> clipNames = new List <string>(sprite.Library.clips.Length);
                List <int>    clipIds   = new List <int>(sprite.Library.clips.Length);

                // fill names (with ids if necessary)
                for (int i = 0; i < sprite.Library.clips.Length; ++i)
                {
                    if (sprite.Library.clips[i].name != null && sprite.Library.clips[i].name.Length > 0)
                    {
                        string name = sprite.Library.clips[i].name;
                        if (tk2dPreferences.inst.showIds)
                        {
                            name += "\t[" + i.ToString() + "]";
                        }
                        clipNames.Add(name);
                        clipIds.Add(i);
                    }
                }

                int newClipId = EditorGUILayout.IntPopup("Clip", sprite.DefaultClipId, clipNames.ToArray(), clipIds.ToArray());
                if (newClipId != sprite.DefaultClipId)
                {
                    Undo.RegisterUndo(targetAnimators, "Sprite Anim Clip");
                    foreach (tk2dSpriteAnimator animator in targetAnimators)
                    {
                        animator.DefaultClipId = newClipId;

                        if (animator.Sprite != null)
                        {
                            // automatically switch to the first frame of the new clip
                            animator.Sprite.SetSprite(animator.Library.clips[animator.DefaultClipId].frames[0].spriteCollection,
                                                      animator.Library.clips[animator.DefaultClipId].frames[0].spriteId);
                        }
                    }
                }
            }

            // Play automatically
            bool newPlayAutomatically = EditorGUILayout.Toggle("Play automatically", sprite.playAutomatically);
            if (newPlayAutomatically != sprite.playAutomatically)
            {
                Undo.RegisterUndo(targetAnimators, "Sprite Anim Play Automatically");
                foreach (tk2dSpriteAnimator animator in targetAnimators)
                {
                    animator.playAutomatically = newPlayAutomatically;
                }
            }

            if (GUI.changed)
            {
                foreach (tk2dSpriteAnimator spr in targetAnimators)
                {
                    EditorUtility.SetDirty(spr);
                }
            }
        }
    }
Exemplo n.º 18
0
        /// <summary>
        /// Draws the script details in the gui.
        /// <param name="script">The script to be drawn.</param>
        /// </summary>
        void DrawScriptDetail(Script script)
        {
            GUILayout.BeginVertical(s_Styles.scriptDetailBox);

            // Draw disabled inspector
            if (m_NodeEditor != null && m_SelectedNodeSample != null)
            {
                #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                EditorGUIUtility.LookLikeInspector();
                #endif

                // Store gui enabled
                var guiEnabled = GUI.enabled;
                GUI.enabled = false;

                GUILayout.Space(-1f);
                m_NodeEditor.DrawNode(m_SelectedNodeSample);
                GUILayout.Space(8f);

                // Restore gui enabled
                GUI.enabled = guiEnabled;

                #if UNITY_4_0_0 || UNITY_4_1 || UNITY_4_2
                EditorGUIUtility.LookLikeControls();
                #endif
            }

            // Draws description?
            if (script.description != string.Empty)
            {
                EditorGUILayout.LabelField(string.Empty, "Description: " + script.description, s_Styles.description);
            }

            // Draw parent
            // Update active node
            var activeNode = BehaviourWindow.activeNode;
            UpdateActiveNode(activeNode);

            // Add to a tree
            InternalBehaviourTree activeTree = BehaviourWindow.activeTree;

            if (activeTree != null)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel("Parent");
                if (activeNode != null && m_ActiveNodeType != null)
                {
                    EditorGUILayout.LabelField(new GUIContent(activeNode.name + m_ActiveNodeTypeName, m_ActiveNodeIcon, m_ActiveNodeInfo.description), s_Styles.titleText);
                }
                else
                {
                    EditorGUILayout.LabelField("null", s_Styles.errorLabel);
                }
                GUILayout.EndHorizontal();

                var guiEnabled2  = GUI.enabled;
                var activeBranch = BehaviourWindow.activeNode as BranchNode;
                GUI.enabled = activeTree != null;
                if (GUILayout.Button(activeBranch != null ? "Add as Child of " + activeBranch.name : "Add as Root", GUILayout.ExpandWidth(false)))
                {
                    ActionNode newNode = null;
                    if (activeBranch != null)
                    {
                        newNode = BehaviourTreeUtility.AddNode(activeBranch, script.type);
                    }
                    else
                    {
                        newNode = BehaviourTreeUtility.AddNode(activeTree, script.type);
                    }

                    // Select the new node
                    if (newNode != null)
                    {
                        BehaviourWindow.activeNodeID = newNode.instanceID;
                    }
                }
                GUI.enabled = guiEnabled2;
            }
            else
            {
                // Add to an ActionState
                var actionState = BehaviourWindow.activeState as InternalActionState;

                if (actionState != null && GUILayout.Button("Add Node", GUILayout.ExpandWidth(false)))
                {
                    ActionNode newNode = ActionStateUtility.AddNode(actionState, script.type);
                    // Select the new node
                    if (newNode != null)
                    {
                        BehaviourWindow.activeNodeID = newNode.instanceID;
                    }
                }
            }

            GUILayout.EndVertical();

            GUILayout.Space(18f);

            // Workaround to avoid to close the GUIPropertyField on click
            if (Event.current.type == EventType.Repaint)
            {
                m_LastRect = GUILayoutUtility.GetLastRect();
            }
            if (Event.current.type == EventType.MouseDown && m_LastRect.Contains(Event.current.mousePosition))
            {
                Event.current.Use();
            }
        }
Exemplo n.º 19
0
    override public void OnInspectorGUI()
    {
        serializedObject.Update();
        SkeletonComponent component = (SkeletonComponent)target;

        EditorGUIUtility.LookLikeInspector();
        EditorGUILayout.PropertyField(skeletonDataAsset);

        if (component.skeleton != null)
        {
            // Initial skin name.
            String[] skins     = new String[component.skeleton.Data.Skins.Count + 1];
            int      skinIndex = 0;
            for (int i = 0; i < skins.Length - 1; i++)
            {
                String name = component.skeleton.Data.Skins[i].Name;
                skins[i] = name;
                if (name == initialSkinName.stringValue)
                {
                    skinIndex = i;
                }
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Initial Skin");
            EditorGUIUtility.LookLikeControls();
            skinIndex = EditorGUILayout.Popup(skinIndex, skins);
            EditorGUIUtility.LookLikeInspector();
            EditorGUILayout.EndHorizontal();

            initialSkinName.stringValue = skinIndex == 0 ? null : skins[skinIndex];

            // Animation name.
            String[] animations = new String[component.skeleton.Data.Animations.Count + 2];
            animations[0] = "<No Change>";
            animations[1] = "<None>";
            int animationIndex = useAnimationName.boolValue ? 1 : 0;
            for (int i = 0; i < animations.Length - 2; i++)
            {
                String name = component.skeleton.Data.Animations[i].Name;
                animations[i + 2] = name;
                if (name == animationName.stringValue)
                {
                    animationIndex = i + 2;
                }
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Animation");
            EditorGUIUtility.LookLikeControls();
            animationIndex = EditorGUILayout.Popup(animationIndex, animations);
            EditorGUIUtility.LookLikeInspector();
            EditorGUILayout.EndHorizontal();

            if (animationIndex == 0)
            {
                animationName.stringValue  = null;
                useAnimationName.boolValue = false;
            }
            else if (animationIndex == 1)
            {
                animationName.stringValue  = null;
                useAnimationName.boolValue = true;
            }
            else
            {
                animationName.stringValue  = animations[animationIndex];
                useAnimationName.boolValue = true;
            }
        }

        // Animation loop.
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Loop");
        loop.boolValue = EditorGUILayout.Toggle(loop.boolValue);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.PropertyField(timeScale);

        if (serializedObject.ApplyModifiedProperties() ||
            (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
            )
        {
            if (!Application.isPlaying)
            {
                component.Clear();
                component.Update();
            }
        }
    }
Exemplo n.º 20
0
        public override void OnInspectorGUI(NavGraph target)
        {
            GridGraph graph = target as GridGraph;

            //GUILayout.BeginHorizontal ();
            //GUILayout.BeginVertical ();
            Rect lockRect;

            GUIStyle lockStyle = AstarPathEditor.astarSkin.FindStyle("GridSizeLock");

            if (lockStyle == null)
            {
                lockStyle = new GUIStyle();
            }

        #if !UNITY_LE_4_3 || true
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            int newWidth = EditorGUILayout.IntField(new GUIContent("Width (nodes)", "Width of the graph in nodes"), graph.width);
            int newDepth = EditorGUILayout.IntField(new GUIContent("Depth (nodes)", "Depth (or height you might also call it) of the graph in nodes"), graph.depth);
            GUILayout.EndVertical();

            lockRect = GUILayoutUtility.GetRect(lockStyle.fixedWidth, lockStyle.fixedHeight);

            // Add a small offset to make it better centred around the controls
            lockRect.y += 3;
            GUILayout.EndHorizontal();

            // All the layouts mess up the margin to the next control, so add it manually
            GUILayout.Space(2);
        #elif UNITY_4
            Rect tmpLockRect;
            int  newWidth = IntField(new GUIContent("Width (nodes)", "Width of the graph in nodes"), graph.width, 100, 0, out lockRect, out sizeSelected1);
            int  newDepth = IntField(new GUIContent("Depth (nodes)", "Depth (or height you might also call it) of the graph in nodes"), graph.depth, 100, 0, out tmpLockRect, out sizeSelected2);
        #else
            Rect tmpLockRect;
            int  newWidth = IntField(new GUIContent("Width (nodes)", "Width of the graph in nodes"), graph.width, 50, 0, out lockRect, out sizeSelected1);
            int  newDepth = IntField(new GUIContent("Depth (nodes)", "Depth (or height you might also call it) of the graph in nodes"), graph.depth, 50, 0, out tmpLockRect, out sizeSelected2);
        #endif

            lockRect.width  = lockStyle.fixedWidth;
            lockRect.height = lockStyle.fixedHeight;
            lockRect.x     += lockStyle.margin.left;
            lockRect.y     += lockStyle.margin.top;

            locked = GUI.Toggle(lockRect, locked, new GUIContent("", "If the width and depth values are locked, changing the node size will scale the grid which keeping the number of nodes consistent instead of keeping the size the same and changing the number of nodes in the graph"), lockStyle);

            //GUILayout.EndHorizontal ();

            if (newWidth != graph.width || newDepth != graph.depth)
            {
                SnapSizeToNodes(newWidth, newDepth, graph);
            }

            GUI.SetNextControlName("NodeSize");
            newNodeSize = EditorGUILayout.FloatField(new GUIContent("Node size", "The size of a single node. The size is the side of the node square in world units"), graph.nodeSize);

            newNodeSize = newNodeSize <= 0.01F ? 0.01F : newNodeSize;

            float prevRatio = graph.aspectRatio;
            graph.aspectRatio = EditorGUILayout.FloatField(new GUIContent("Aspect Ratio", "Scaling of the nodes width/depth ratio. Good for isometric games"), graph.aspectRatio);

            graph.isometricAngle = EditorGUILayout.FloatField(new GUIContent("Isometric Angle", "For an isometric 2D game, you can use this parameter to scale the graph correctly."), graph.isometricAngle);

            if (graph.nodeSize != newNodeSize || prevRatio != graph.aspectRatio)
            {
                if (!locked)
                {
                    graph.nodeSize = newNodeSize;
                    Matrix4x4 oldMatrix = graph.matrix;
                    graph.GenerateMatrix();
                    if (graph.matrix != oldMatrix)
                    {
                        //Rescann the graphs
                        //AstarPath.active.AutoScan ();
                        GUI.changed = true;
                    }
                }
                else
                {
                    float delta = newNodeSize / graph.nodeSize;
                    graph.nodeSize      = newNodeSize;
                    graph.unclampedSize = new Vector2(newWidth * graph.nodeSize, newDepth * graph.nodeSize);
                    Vector3 newCenter = graph.matrix.MultiplyPoint3x4(new Vector3((newWidth / 2F) * delta, 0, (newDepth / 2F) * delta));
                    graph.center = newCenter;
                    graph.GenerateMatrix();

                    //Make sure the width & depths stay the same
                    graph.width = newWidth;
                    graph.depth = newDepth;
                    AutoScan();
                }
            }

            Vector3 pivotPoint;
            Vector3 diff;

        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeControls();
        #endif

        #if !UNITY_4
            EditorGUILayoutx.BeginIndent();
        #else
            GUILayout.BeginHorizontal();
        #endif

            switch (pivot)
            {
            case GridPivot.Center:
                graph.center = RoundVector3(graph.center);
                graph.center = EditorGUILayout.Vector3Field("Center", graph.center);
                break;

            case GridPivot.TopLeft:
                pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(0, 0, graph.depth));
                pivotPoint   = RoundVector3(pivotPoint);
                diff         = pivotPoint - graph.center;
                pivotPoint   = EditorGUILayout.Vector3Field("Top-Left", pivotPoint);
                graph.center = pivotPoint - diff;
                break;

            case GridPivot.TopRight:
                pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(graph.width, 0, graph.depth));
                pivotPoint   = RoundVector3(pivotPoint);
                diff         = pivotPoint - graph.center;
                pivotPoint   = EditorGUILayout.Vector3Field("Top-Right", pivotPoint);
                graph.center = pivotPoint - diff;
                break;

            case GridPivot.BottomLeft:
                pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(0, 0, 0));
                pivotPoint   = RoundVector3(pivotPoint);
                diff         = pivotPoint - graph.center;
                pivotPoint   = EditorGUILayout.Vector3Field("Bottom-Left", pivotPoint);
                graph.center = pivotPoint - diff;
                break;

            case GridPivot.BottomRight:
                pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(graph.width, 0, 0));
                pivotPoint   = RoundVector3(pivotPoint);
                diff         = pivotPoint - graph.center;
                pivotPoint   = EditorGUILayout.Vector3Field("Bottom-Right", pivotPoint);
                graph.center = pivotPoint - diff;
                break;
            }

            graph.GenerateMatrix();

            pivot = PivotPointSelector(pivot);

        #if !UNITY_4
            EditorGUILayoutx.EndIndent();

            EditorGUILayoutx.BeginIndent();
        #else
            GUILayout.EndHorizontal();
        #endif

            graph.rotation = EditorGUILayout.Vector3Field("Rotation", graph.rotation);

        #if UNITY_LE_4_3
            //Add some space to make the Rotation and postion fields be better aligned (instead of the pivot point selector)
            //GUILayout.Space (19+7);
        #endif
            //GUILayout.EndHorizontal ();

        #if !UNITY_4
            EditorGUILayoutx.EndIndent();
        #endif
        #if UNITY_LE_4_3
            EditorGUIUtility.LookLikeInspector();
        #endif

            if (GUILayout.Button(new GUIContent("Snap Size", "Snap the size to exactly fit nodes"), GUILayout.MaxWidth(100), GUILayout.MaxHeight(16)))
            {
                SnapSizeToNodes(newWidth, newDepth, graph);
            }

            Separator();

            graph.cutCorners = EditorGUILayout.Toggle(new GUIContent("Cut Corners", "Enables or disables cutting corners. See docs for image example"), graph.cutCorners);
            graph.neighbours = (NumNeighbours)EditorGUILayout.EnumPopup(new GUIContent("Connections", "Sets how many connections a node should have to it's neighbour nodes."), graph.neighbours);

            graph.maxClimb = EditorGUILayout.FloatField(new GUIContent("Max Climb", "How high, relative to the graph, should a climbable level be. A zero (0) indicates infinity"), graph.maxClimb);
            if (graph.maxClimb < 0)
            {
                graph.maxClimb = 0;
            }
            EditorGUI.indentLevel++;
            graph.maxClimbAxis = EditorGUILayout.IntPopup(new GUIContent("Climb Axis", "Determines which axis the above setting should test on"), graph.maxClimbAxis, new GUIContent[3] {
                new GUIContent("X"), new GUIContent("Y"), new GUIContent("Z")
            }, new int[3] {
                0, 1, 2
            });
            EditorGUI.indentLevel--;

            if (graph.maxClimb > 0 && Mathf.Abs((Quaternion.Euler(graph.rotation) * new Vector3(graph.nodeSize, 0, graph.nodeSize))[graph.maxClimbAxis]) > graph.maxClimb)
            {
                EditorGUILayout.HelpBox("Nodes are spaced further apart than this in the grid. You might want to increase this value or change the axis", MessageType.Warning);
            }

            //GUILayout.EndHorizontal ();

            graph.maxSlope = EditorGUILayout.Slider(new GUIContent("Max Slope", "Sets the max slope in degrees for a point to be walkable. Only enabled if Height Testing is enabled."), graph.maxSlope, 0, 90F);

            graph.erodeIterations = EditorGUILayout.IntField(new GUIContent("Erosion iterations", "Sets how many times the graph should be eroded. This adds extra margin to objects. This will not work when using Graph Updates, so if you can, use the Diameter setting in collision settings instead"), graph.erodeIterations);
            graph.erodeIterations = graph.erodeIterations < 0 ? 0 : (graph.erodeIterations > 16 ? 16 : graph.erodeIterations);             //Clamp iterations to [0,16]

            if (graph.erodeIterations > 0)
            {
                EditorGUI.indentLevel++;
                graph.erosionUseTags = EditorGUILayout.Toggle(new GUIContent("Erosion Uses Tags", "Instead of making nodes unwalkable, " +
                                                                             "nodes will have their tag set to a value corresponding to their erosion level, " +
                                                                             "which is a quite good measurement of their distance to the closest wall.\nSee online documentation for more info."),
                                                              graph.erosionUseTags);
                if (graph.erosionUseTags)
                {
                    EditorGUI.indentLevel++;
                    graph.erosionFirstTag = EditorGUILayoutx.SingleTagField("First Tag", graph.erosionFirstTag);
                    EditorGUI.indentLevel--;
                }
                EditorGUI.indentLevel--;
            }
            DrawCollisionEditor(graph.collision);

            if (graph.collision.use2D)
            {
                if (Mathf.Abs(Vector3.Dot(Vector3.forward, Quaternion.Euler(graph.rotation) * Vector3.up)) < 0.9f)
                {
                    EditorGUILayout.HelpBox("When using 2D it is recommended to rotate the graph so that it aligns with the 2D plane.", MessageType.Warning);
                }
            }

            Separator();
            GUILayout.Label(new GUIContent("Advanced"), EditorStyles.boldLabel);

            showExtra = EditorGUILayout.Foldout(showExtra, "Penalty Modifications");

            if (showExtra)
            {
                EditorGUI.indentLevel += 2;

                graph.penaltyAngle = ToggleGroup(new GUIContent("Angle Penalty", "Adds a penalty based on the slope of the node"), graph.penaltyAngle);
                //bool preGUI = GUI.enabled;
                //GUI.enabled = graph.penaltyAngle && GUI.enabled;
                if (graph.penaltyAngle)
                {
                    EditorGUI.indentLevel++;
                    graph.penaltyAngleFactor = EditorGUILayout.FloatField(new GUIContent("Factor", "Scale of the penalty. A negative value should not be used"), graph.penaltyAngleFactor);
                    graph.penaltyAnglePower  = EditorGUILayout.Slider("Power", graph.penaltyAnglePower, 0.1f, 10f);
                    //GUI.enabled = preGUI;
                    HelpBox("Applies penalty to nodes based on the angle of the hit surface during the Height Testing\nPenalty applied is: P=(1-cos(angle)^power)*factor.");

                    EditorGUI.indentLevel--;
                }

                graph.penaltyPosition = ToggleGroup("Position Penalty", graph.penaltyPosition);
                //EditorGUILayout.Toggle ("Position Penalty",graph.penaltyPosition);
                //preGUI = GUI.enabled;
                //GUI.enabled = graph.penaltyPosition && GUI.enabled;
                if (graph.penaltyPosition)
                {
                    EditorGUI.indentLevel++;
                    graph.penaltyPositionOffset = EditorGUILayout.FloatField("Offset", graph.penaltyPositionOffset);
                    graph.penaltyPositionFactor = EditorGUILayout.FloatField("Factor", graph.penaltyPositionFactor);
                    HelpBox("Applies penalty to nodes based on their Y coordinate\nSampled in Int3 space, i.e it is multiplied with Int3.Precision first (" + Int3.Precision + ")\n" +
                            "Be very careful when using negative values since a negative penalty will underflow and instead get really high");
                    //GUI.enabled = preGUI;
                    EditorGUI.indentLevel--;
                }

                GUI.enabled = false;
                ToggleGroup(new GUIContent("Use Texture", AstarPathEditor.AstarProTooltip), false);
                GUI.enabled            = true;
                EditorGUI.indentLevel -= 2;
            }
        }
Exemplo n.º 21
0
    public override void OnInspectorGUI()
    {
        #if UNITY_3_5
        EditorGUIUtility.LookLikeInspector();
        #endif
        EditorGUI.indentLevel = 1;

        PhotonView mp = (PhotonView)this.target;
        bool       isProjectPrefab = EditorUtility.IsPersistent(mp.gameObject);



        // Owner
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("Owner:", "Set at runtime");
        }
        else if (mp.isSceneView)
        {
            EditorGUILayout.LabelField("Owner:", "Scene");
        }
        else
        {
            PhotonPlayer owner     = mp.owner;
            string       ownerInfo = (owner != null) ? owner.name : "<no PhotonPlayer found>";

            if (string.IsNullOrEmpty(ownerInfo))
            {
                ownerInfo = "<no playername set>";
            }

            EditorGUILayout.LabelField("Owner:", "[" + mp.ownerId + "] " + ownerInfo);
        }



        // View ID
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("View ID", "Set at runtime");
        }
        else if (EditorApplication.isPlaying)
        {
            EditorGUILayout.LabelField("View ID", mp.viewID.ToString());
        }
        else
        {
            int idValue = EditorGUILayout.IntField("View ID [0.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", mp.viewID);
            mp.viewID = idValue;
        }



        // Locally Controlled
        if (EditorApplication.isPlaying)
        {
            string masterClientHint = PhotonNetwork.isMasterClient ? "(master)" : "";
            EditorGUILayout.Toggle("Controlled locally: " + masterClientHint, mp.isMine);
        }



        // Observed Item
        EditorGUILayout.BeginHorizontal();

        // Using a lower version then 3.4? Remove the TRUE in the next line to fix an compile error
        string typeOfObserved = string.Empty;
        if (mp.observed != null)
        {
            int firstBracketPos = mp.observed.ToString().LastIndexOf('(');
            if (firstBracketPos > 0)
            {
                typeOfObserved = mp.observed.ToString().Substring(firstBracketPos);
            }
        }


        Component componenValue = (Component)EditorGUILayout.ObjectField("Observe: " + typeOfObserved, mp.observed, typeof(Component), true);
        if (mp.observed != componenValue)
        {
            if (mp.observed == null)
            {
                mp.synchronization = ViewSynchronization.UnreliableOnChange;    // if we didn't observe anything yet. use unreliable on change as default
            }
            if (componenValue == null)
            {
                mp.synchronization = ViewSynchronization.Off;
            }

            mp.observed = componenValue;
        }

        EditorGUILayout.EndHorizontal();



        // ViewSynchronization (reliability)
        if (mp.synchronization == ViewSynchronization.Off)
        {
            GUI.color = Color.grey;
        }

        ViewSynchronization vsValue = (ViewSynchronization)EditorGUILayout.EnumPopup("Observe option:", mp.synchronization);
        if (vsValue != mp.synchronization)
        {
            mp.synchronization = vsValue;
            if (mp.synchronization != ViewSynchronization.Off && mp.observed == null)
            {
                EditorUtility.DisplayDialog("Warning", "Setting the synchronization option only makes sense if you observe something.", "OK, I will fix it.");
            }
        }



        // Serialization
        // show serialization options only if something is observed
        if (mp.observed != null)
        {
            Type type = mp.observed.GetType();
            if (type == typeof(Transform))
            {
                mp.onSerializeTransformOption = (OnSerializeTransform)EditorGUILayout.EnumPopup("Serialization:", mp.onSerializeTransformOption);
            }
            else if (type == typeof(Rigidbody))
            {
                mp.onSerializeRigidBodyOption = (OnSerializeRigidBody)EditorGUILayout.EnumPopup("Serialization:", mp.onSerializeRigidBodyOption);
            }
        }



        // Cleanup: save and fix look
        if (GUI.changed)
        {
            EditorUtility.SetDirty(mp);
            PhotonViewHandler.HierarchyChange();  // TODO: check if needed
        }

        GUI.color = Color.white;
        EditorGUIUtility.LookLikeControls();
    }
Exemplo n.º 22
0
    public override void OnInspectorGUI()
    {
        EasyTouch t = (EasyTouch)target;

        HTGUILayout.FoldOut(ref t.showGeneral, "General properties", false);
        if (t.showGeneral)
        {
            if (t.enable)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enable = EditorGUILayout.Toggle("Enable EasyTouch", t.enable);
            if (t.enableRemote)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enableRemote = EditorGUILayout.Toggle("Enable unity remote", t.enableRemote);


            if (t.useBroadcastMessage)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.useBroadcastMessage = EditorGUILayout.BeginToggleGroup("Broadcast messages", t.useBroadcastMessage);
            GUI.backgroundColor   = Color.white;
            if (t.useBroadcastMessage)
            {
                EditorGUILayout.BeginVertical(paddingStyle1);
                t.receiverObject = (GameObject)EditorGUILayout.ObjectField("Other receiver", t.receiverObject, typeof(GameObject), true);
                if (t.isExtension)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.isExtension       = EditorGUILayout.Toggle("Joysticks & buttons", t.isExtension);
                GUI.backgroundColor = Color.white;
                EditorGUILayout.EndVertical();
            }

            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.Space();

            if (t.enableReservedArea)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enableReservedArea = EditorGUILayout.Toggle("Enable reserved area", t.enableReservedArea);
            EditorGUILayout.Space();
            if (t.enabledNGuiMode)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.red;
            }
            t.enabledNGuiMode   = EditorGUILayout.Toggle("Enable NGUI compatibilty", t.enabledNGuiMode);
            GUI.backgroundColor = Color.white;
            if (t.enabledNGuiMode)
            {
                EditorGUILayout.BeginVertical(paddingStyle1);

                // Camera
                serializedObject.Update();
                EditorGUIUtility.LookLikeInspector();
                SerializedProperty cameras = serializedObject.FindProperty("nGUICameras");
                EditorGUILayout.PropertyField(cameras, true);
                serializedObject.ApplyModifiedProperties();
                EditorGUIUtility.LookLikeControls();

                EditorGUILayout.Space();

                // layers
                serializedObject.Update();
                EditorGUIUtility.LookLikeInspector();
                SerializedProperty layers = serializedObject.FindProperty("nGUILayers");
                EditorGUILayout.PropertyField(layers, false);
                serializedObject.ApplyModifiedProperties();
                EditorGUIUtility.LookLikeControls();

                EditorGUILayout.EndVertical();
            }
        }

        if (t.enable)
        {
            // Auto select porperties
            HTGUILayout.FoldOut(ref t.showSelect, "Auto-select properties", false);
            if (t.showSelect)
            {
                t.easyTouchCamera = (Camera)EditorGUILayout.ObjectField("Camera", t.easyTouchCamera, typeof(Camera), true);
                if (t.autoSelect)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.autoSelect        = EditorGUILayout.Toggle("Enable auto-select", t.autoSelect);
                GUI.backgroundColor = Color.white;
                if (t.autoSelect)
                {
                    serializedObject.Update();
                    EditorGUIUtility.LookLikeInspector();
                    SerializedProperty layers = serializedObject.FindProperty("pickableLayers");
                    EditorGUILayout.PropertyField(layers, true);
                    serializedObject.ApplyModifiedProperties();
                    EditorGUIUtility.LookLikeControls();
                }
            }

            // General gesture properties
            HTGUILayout.FoldOut(ref t.showGesture, "General gesture properties", false);
            if (t.showGesture)
            {
                t.StationnaryTolerance = EditorGUILayout.FloatField("Stationary tolerance", t.StationnaryTolerance);
                t.longTapTime          = EditorGUILayout.FloatField("Long tap time", t.longTapTime);
                t.swipeTolerance       = EditorGUILayout.FloatField("Swipe tolerance", t.swipeTolerance);
            }

            // Two fingers gesture
            HTGUILayout.FoldOut(ref t.showTwoFinger, "Two fingers gesture properties", false);
            if (t.showTwoFinger)
            {
                if (t.enable2FingersGesture)
                {
                    GUI.backgroundColor = Color.green;
                }
                else
                {
                    GUI.backgroundColor = Color.red;
                }
                t.enable2FingersGesture = EditorGUILayout.Toggle("2 fingers gesture", t.enable2FingersGesture);
                GUI.backgroundColor     = Color.white;
                if (t.enable2FingersGesture)
                {
                    EditorGUILayout.Separator();
                    if (t.enablePinch)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    t.enablePinch       = EditorGUILayout.Toggle("Enable Pinch", t.enablePinch);
                    GUI.backgroundColor = Color.white;
                    if (t.enablePinch)
                    {
                        t.minPinchLength = EditorGUILayout.FloatField("Min pinch length", t.minPinchLength);
                    }
                    EditorGUILayout.Separator();
                    if (t.enableTwist)
                    {
                        GUI.backgroundColor = Color.green;
                    }
                    else
                    {
                        GUI.backgroundColor = Color.red;
                    }
                    t.enableTwist       = EditorGUILayout.Toggle("Enable twist", t.enableTwist);
                    GUI.backgroundColor = Color.white;
                    if (t.enableTwist)
                    {
                        t.minTwistAngle = EditorGUILayout.FloatField("Min twist angle", t.minTwistAngle);
                    }

                    EditorGUILayout.Separator();
                }
            }

            // Second Finger simulation
            HTGUILayout.FoldOut(ref t.showSecondFinger, "Second finger simulation", false);
            if (t.showSecondFinger)
            {
                if (t.secondFingerTexture == null)
                {
                    t.secondFingerTexture = Resources.Load("secondFinger") as Texture;
                }

                t.secondFingerTexture = (Texture)EditorGUILayout.ObjectField("Texture", t.secondFingerTexture, typeof(Texture), true);
                EditorGUILayout.HelpBox("Change the keys settings for a fash compilation, or if you want to change the keys", MessageType.Info);
                t.twistKey = (KeyCode)EditorGUILayout.EnumPopup("Twist & pinch key", t.twistKey);
                t.swipeKey = (KeyCode)EditorGUILayout.EnumPopup("Swipe key", t.swipeKey);
            }
        }
    }
Exemplo n.º 23
0
    public override void OnInspectorGUI()
    {
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_2
        EditorGUIUtility.LookLikeInspector();
#else
        EditorGUIUtility.labelWidth = 210;
#endif
        GUILayout.Label(Strings.Label_NOTES, EditorStyles.boldLabel);
        GUILayout.Label(Strings.Hint_PlayMakerGUI_Notes);
        GUILayout.Label(Strings.Label_General, EditorStyles.boldLabel);

        EditorGUI.indentLevel = 1;

        guiComponent.enableGUILayout = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Enable_GUILayout,
                                                                             Strings.Tooltip_Enable_GUILayout),
                                                              guiComponent.enableGUILayout);
        guiComponent.controlMouseCursor = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Control_Mouse_Cursor,
                                                                                Strings.Tooltip_Control_Mouse_Cursor),
                                                                 guiComponent.controlMouseCursor);

        guiComponent.previewOnGUI = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Preview_GUI_Actions_While_Editing, Strings.Tooltip_Preview_GUI_Actions_While_Editing), guiComponent.previewOnGUI);

        EditorGUI.indentLevel = 0;
        GUILayout.Label(Strings.Label_Debugging, EditorStyles.boldLabel);
        EditorGUI.indentLevel = 1;

        var drawStateLabels = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Draw_Active_State_Labels, Strings.Tooltip_Draw_Active_State_Labels), guiComponent.drawStateLabels);
        if (drawStateLabels != guiComponent.drawStateLabels)
        {
            guiComponent.drawStateLabels = drawStateLabels;
            FsmEditorSettings.ShowStateLabelsInGameView = drawStateLabels;
            FsmEditorSettings.SaveSettings();
        }

        GUI.enabled = guiComponent.drawStateLabels;
        //EditorGUI.indentLevel = 2;

        var enableStateLabelsInBuilds = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Enable_State_Labels_in_Builds, Strings.Tooltip_Show_State_Labels_in_Standalone_Builds), guiComponent.enableStateLabelsInBuilds);
        if (enableStateLabelsInBuilds != guiComponent.enableStateLabelsInBuilds)
        {
            guiComponent.enableStateLabelsInBuilds   = enableStateLabelsInBuilds;
            FsmEditorSettings.ShowStateLabelsInBuild = enableStateLabelsInBuilds;
            FsmEditorSettings.SaveSettings();
        }

        guiComponent.GUITextureStateLabels = EditorGUILayout.Toggle(new GUIContent(Strings.Label_GUITexture_State_Labels, Strings.Tooltip_GUITexture_State_Labels), guiComponent.GUITextureStateLabels);
        guiComponent.GUITextStateLabels    = EditorGUILayout.Toggle(new GUIContent(Strings.Label_GUIText_State_Labels, Strings.Tooltip_GUIText_State_Labels), guiComponent.GUITextStateLabels);

        GUI.enabled = true;
        //EditorGUI.indentLevel = 1;

        guiComponent.filterLabelsWithDistance = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Filter_State_Labels_With_Distance, Strings.Tooltip_Filter_State_Labels_With_Distance), guiComponent.filterLabelsWithDistance);

        GUI.enabled = guiComponent.filterLabelsWithDistance;

        guiComponent.maxLabelDistance = EditorGUILayout.FloatField(new GUIContent(Strings.Label_Camera_Distance, Strings.Tooltip_Camera_Distance), guiComponent.maxLabelDistance);

        GUI.enabled = true;

        guiComponent.labelScale = EditorGUILayout.FloatField(new GUIContent(Strings.Label_State_Label_Scale, Strings.Tooltip_State_Label_Scale), guiComponent.labelScale);
        if (guiComponent.labelScale < 0.1f)
        {
            guiComponent.labelScale = 0.1f;
        }
        if (guiComponent.labelScale > 10f)
        {
            guiComponent.labelScale = 10f;
        }

        if (GUI.changed)
        {
            CheckForDuplicateComponents();
        }
    }
    //[DrawGizmo(GizmoType.SelectedOrChild)]
    //static void RenderGizmoSelected(ModifyObject mod, GizmoType gizmoType)
    //{
    //mod.ColliderTest();
    //}

    public override void OnInspectorGUI()
    {
        MegaModifyObject mod = (MegaModifyObject)target;

        //showhelp = EditorGUILayout.Foldout(showhelp, "Help");

        //if ( showhelp )
        //{
        //if ( image == null )
        //image = (Texture)EditorGUIUtility.LoadRequired("mod_help.png");

        //if ( image != null )
        //{
        //float w = Screen.width - 12.0f;
        //float h = (w / image.width) * image.height;
        //GUILayout.Label((Texture)image, GUIStyle.none, GUILayout.Width(w), GUILayout.Height(h));
        //}
        //}

        EditorGUIUtility.LookLikeInspector();
        MegaModifiers.GlobalDisplay = EditorGUILayout.Toggle("GlobalDisplayGizmos", MegaModifiers.GlobalDisplay);
        mod.Enabled     = EditorGUILayout.Toggle("Enabled", mod.Enabled);
        mod.recalcnorms = EditorGUILayout.Toggle("Recalc Normals", mod.recalcnorms);
        MegaNormalMethod method = mod.NormalMethod;

        mod.NormalMethod    = (MegaNormalMethod)EditorGUILayout.EnumPopup("Normal Method", mod.NormalMethod);
        mod.recalcbounds    = EditorGUILayout.Toggle("Recalc Bounds", mod.recalcbounds);
        mod.recalcCollider  = EditorGUILayout.Toggle("Recalc Collider", mod.recalcCollider);
        mod.recalcTangents  = EditorGUILayout.Toggle("Recalc Tangents", mod.recalcTangents);
        mod.DoLateUpdate    = EditorGUILayout.Toggle("Do Late Update", mod.DoLateUpdate);
        mod.InvisibleUpdate = EditorGUILayout.Toggle("Invisible Update", mod.InvisibleUpdate);
        mod.GrabVerts       = EditorGUILayout.Toggle("Grab Verts", mod.GrabVerts);
        mod.DrawGizmos      = EditorGUILayout.Toggle("Draw Gizmos", mod.DrawGizmos);

        if (mod.NormalMethod != method && mod.NormalMethod == MegaNormalMethod.Mega)
        {
            mod.BuildNormalMapping(mod.mesh, false);
        }

        //showmulti = EditorGUILayout.Foldout(showmulti, "Multi Core");
#if !UNITY_FLASH
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Copy Object"))
        {
            GameObject obj = MegaCopyObject.DoCopyObjects(mod.gameObject);
            if (obj)
            {
                obj.transform.position = mod.gameObject.transform.position;

                Selection.activeGameObject = obj;
            }
        }

        if (GUILayout.Button("Copy Hierarchy"))
        {
            GameObject obj = MegaCopyObject.DoCopyObjectsChildren(mod.gameObject);
            Selection.activeGameObject = obj;
        }

        EditorGUILayout.EndHorizontal();
#endif
        if (GUILayout.Button("Threading Options"))
        {
            showmulti = !showmulti;
        }

        if (showmulti)
        {
            MegaModifiers.ThreadingOn = EditorGUILayout.Toggle("Threading Enabled", MegaModifiers.ThreadingOn);
            mod.UseThreading          = EditorGUILayout.Toggle("Thread This Object", mod.UseThreading);
        }

        EditorGUIUtility.LookLikeControls();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }

        showorder = EditorGUILayout.Foldout(showorder, "Modifier Order");

        if (showorder && mod.mods != null)
        {
            for (int i = 0; i < mod.mods.Length; i++)
            {
                EditorGUILayout.LabelField("", i.ToString() + " - " + mod.mods[i].ModName() + " " + mod.mods[i].Order);
            }
        }

        // Group stuff
        if (GUILayout.Button("Group Members"))
        {
            showgroups = !showgroups;
        }

        if (showgroups)
        {
            //if ( GUILayout.Button("Add Object") )
            //{
            //MegaModifierTarget targ = new MegaModifierTarget();
            //	mod.group.Add(targ);
            //}

            for (int i = 0; i < mod.group.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                mod.group[i] = (GameObject)EditorGUILayout.ObjectField("Obj " + i, mod.group[i], typeof(GameObject), true);
                if (GUILayout.Button("Del"))
                {
                    mod.group.Remove(mod.group[i]);
                    i--;
                }
                EditorGUILayout.EndHorizontal();
            }

            GameObject newobj = (GameObject)EditorGUILayout.ObjectField("Add", null, typeof(GameObject), true);
            if (newobj)
            {
                mod.group.Add(newobj);
            }

            if (GUILayout.Button("Update"))
            {
                // for each group member check if it has a modify object comp, if not add one and copy values over
                // calculate box for all meshes and set, and set the Offset for each one
                // then for each modifier attached find or add and set instance value
                // in theory each gizmo should overlap the others

                // Have a method to update box and offsets if we allow moving in the group
            }
        }

        //if ( GUILayout.Button("Create Copy") )
        //{
        //	CloneObject();
        //}
    }
Exemplo n.º 25
0
    public override void OnInspectorGUI(NavGraph target)
    {
        GridGraph graph = target as GridGraph;

        //GUILayout.BeginHorizontal ();
        //GUILayout.BeginVertical ();
        Rect lockRect;
        Rect tmpLockRect;

        GUIStyle lockStyle = AstarPathEditor.astarSkin.FindStyle("GridSizeLock");

        if (lockStyle == null)
        {
            lockStyle = new GUIStyle();
        }

        bool sizeSelected1 = false;
        bool sizeSelected2 = false;

        int offset   = 70;
        int newWidth = IntField(new GUIContent("Width (nodes)", "Width of the graph in nodes"), graph.width, offset, 0, out lockRect, out sizeSelected1);
        int newDepth = IntField(new GUIContent("Depth (nodes)", "Depth (or height you might also call it) of the graph in nodes"), graph.depth, offset, 0, out tmpLockRect, out sizeSelected2);

        //Rect r = GUILayoutUtility.GetRect (0,0,lockStyle);

        lockRect.width  = lockStyle.fixedWidth;
        lockRect.height = lockStyle.fixedHeight;
        lockRect.x     += lockStyle.margin.left;
        lockRect.y     += lockStyle.margin.top;

        locked = GUI.Toggle(lockRect, locked, new GUIContent("", "If the width and depth values are locked, changing the node size will scale the grid which keeping the number of nodes consistent instead of keeping the size the same and changing the number of nodes in the graph"), lockStyle);

        //GUILayout.EndHorizontal ();

        if (newWidth != graph.width || newDepth != graph.depth)
        {
            SnapSizeToNodes(newWidth, newDepth, graph);
        }

        GUI.SetNextControlName("NodeSize");
        newNodeSize = EditorGUILayout.FloatField(new GUIContent("Node size", "The size of a single node. The size is the side of the node square in world units"), graph.nodeSize);

        newNodeSize = newNodeSize <= 0.01F ? 0.01F : newNodeSize;

        float prevRatio = graph.aspectRatio;

        graph.aspectRatio = EditorGUILayout.FloatField(new GUIContent("Aspect Ratio", "Scaling of the nodes width/depth ratio. Good for isometric games"), graph.aspectRatio);


        //if ((GUI.GetNameOfFocusedControl () != "NodeSize" && Event.current.type == EventType.Repaint) || Event.current.keyCode == KeyCode.Return) {

        //Debug.Log ("Node Size Not Selected " + Event.current.type);

        if (graph.nodeSize != newNodeSize || prevRatio != graph.aspectRatio)
        {
            if (!locked)
            {
                graph.nodeSize = newNodeSize;
                Matrix4x4 oldMatrix = graph.matrix;
                graph.GenerateMatrix();
                if (graph.matrix != oldMatrix)
                {
                    //Rescann the graphs
                    //AstarPath.active.AutoScan ();
                    GUI.changed = true;
                }
            }
            else
            {
                float delta = newNodeSize / graph.nodeSize;
                graph.nodeSize      = newNodeSize;
                graph.unclampedSize = new Vector2(newWidth * graph.nodeSize, newDepth * graph.nodeSize);
                Vector3 newCenter = graph.matrix.MultiplyPoint3x4(new Vector3((newWidth / 2F) * delta, 0, (newDepth / 2F) * delta));
                graph.center = newCenter;
                graph.GenerateMatrix();

                //Make sure the width & depths stay the same
                graph.width = newWidth;
                graph.depth = newDepth;
                AstarPath.active.AutoScan();
            }
        }
        //}

        Vector3 pivotPoint;
        Vector3 diff;

        EditorGUIUtility.LookLikeControls();
        EditorGUILayoutx.BeginIndent();

        switch (pivot)
        {
        case GridPivot.Center:
            graph.center = EditorGUILayout.Vector3Field("Center", graph.center);
            break;

        case GridPivot.TopLeft:
            pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(0, 0, graph.depth));
            diff         = pivotPoint - graph.center;
            pivotPoint   = EditorGUILayout.Vector3Field("Top-Left", pivotPoint);
            graph.center = pivotPoint - diff;
            break;

        case GridPivot.TopRight:
            pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(graph.width, 0, graph.depth));
            diff         = pivotPoint - graph.center;
            pivotPoint   = EditorGUILayout.Vector3Field("Top-Right", pivotPoint);
            graph.center = pivotPoint - diff;
            break;

        case GridPivot.BottomLeft:
            pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(0, 0, 0));
            diff         = pivotPoint - graph.center;
            pivotPoint   = EditorGUILayout.Vector3Field("Bottom-Left", pivotPoint);
            graph.center = pivotPoint - diff;
            break;

        case GridPivot.BottomRight:
            pivotPoint   = graph.matrix.MultiplyPoint3x4(new Vector3(graph.width, 0, 0));
            diff         = pivotPoint - graph.center;
            pivotPoint   = EditorGUILayout.Vector3Field("Bottom-Right", pivotPoint);
            graph.center = pivotPoint - diff;
            break;
        }

        graph.GenerateMatrix();

        pivot = PivotPointSelector(pivot);

        EditorGUILayoutx.EndIndent();

        EditorGUILayoutx.BeginIndent();

        graph.rotation = EditorGUILayout.Vector3Field("Rotation", graph.rotation);
        //Add some space to make the Rotation and postion fields be better aligned (instead of the pivot point selector)
        GUILayout.Space(19 + 7);
        //GUILayout.EndHorizontal ();

        EditorGUILayoutx.EndIndent();
        EditorGUIUtility.LookLikeInspector();

        if (GUILayout.Button(new GUIContent("Snap Size", "Snap the size to exactly fit nodes"), GUILayout.MaxWidth(100), GUILayout.MaxHeight(16)))
        {
            SnapSizeToNodes(newWidth, newDepth, graph);
        }

        Separator();

        graph.cutCorners = EditorGUILayout.Toggle(new GUIContent("Cut Corners", "Enables or disables cutting corners. See docs for image example"), graph.cutCorners);
        graph.neighbours = (NumNeighbours)EditorGUILayout.EnumPopup(new GUIContent("Connections", "Sets how many connections a node should have to it's neighbour nodes."), graph.neighbours);

        //GUILayout.BeginHorizontal ();
        //EditorGUILayout.PrefixLabel ("Max Climb");
        graph.maxClimb = EditorGUILayout.FloatField(new GUIContent("Max Climb", "How high, relative to the graph, should a climbable level be. A zero (0) indicates infinity"), graph.maxClimb);
        EditorGUI.indentLevel++;
        graph.maxClimbAxis = EditorGUILayout.IntPopup(new GUIContent("Climb Axis", "Determines which axis the above setting should test on"), graph.maxClimbAxis, new GUIContent[3] {
            new GUIContent("X"), new GUIContent("Y"), new GUIContent("Z")
        }, new int[3] {
            0, 1, 2
        });

        EditorGUI.indentLevel--;
        //GUILayout.EndHorizontal ();

        graph.maxSlope = EditorGUILayout.Slider(new GUIContent("Max Slope", "Sets the max slope in degrees for a point to be walkable. Only enabled if Height Testing is enabled."), graph.maxSlope, 0, 90F);

        graph.erodeIterations = EditorGUILayout.IntField(new GUIContent("Erode iterations", "Sets how many times the graph should be eroded. This adds extra margin to objects. This will not work when using Graph Updates, so if you can, use the Diameter setting in collision settings instead"), graph.erodeIterations);
        graph.erodeIterations = graph.erodeIterations > 16 ? 16 : graph.erodeIterations;         //Clamp iterations to 16

        graph.erosionUseTags = EditorGUILayout.Toggle(new GUIContent("Erosion Uses Tags", "Instead of making nodes unwalkable, " +
                                                                     "nodes will have their tag set to a value corresponding to their erosion level, " +
                                                                     "which is a quite good measurement of their distance to the closest wall."),
                                                      graph.erosionUseTags);
        if (graph.erosionUseTags)
        {
            EditorGUI.indentLevel++;
            graph.erosionFirstTag = EditorGUILayoutx.SingleTagField("First Tag", graph.erosionFirstTag);
            EditorGUI.indentLevel--;
        }

        DrawCollisionEditor(graph.collision);

        Separator();

        showExtra = EditorGUILayout.Foldout(showExtra, "Extra");

        if (showExtra)
        {
            EditorGUI.indentLevel += 2;

            graph.penaltyAngle = ToggleGroup(new GUIContent("Angle Penalty", "Adds a penalty based on the slope of the node"), graph.penaltyAngle);
            //bool preGUI = GUI.enabled;
            //GUI.enabled = graph.penaltyAngle && GUI.enabled;
            if (graph.penaltyAngle)
            {
                EditorGUI.indentLevel++;
                graph.penaltyAngleFactor = EditorGUILayout.FloatField(new GUIContent("Factor", "Scale of the penalty. A negative value should not be used"), graph.penaltyAngleFactor);
                //GUI.enabled = preGUI;
                HelpBox("Applies penalty to nodes based on the angle of the hit surface during the Height Testing");

                EditorGUI.indentLevel--;
            }

            graph.penaltyPosition = ToggleGroup("Position Penalty", graph.penaltyPosition);
            //EditorGUILayout.Toggle ("Position Penalty",graph.penaltyPosition);
            //preGUI = GUI.enabled;
            //GUI.enabled = graph.penaltyPosition && GUI.enabled;
            if (graph.penaltyPosition)
            {
                EditorGUI.indentLevel++;
                graph.penaltyPositionOffset = EditorGUILayout.FloatField("Offset", graph.penaltyPositionOffset);
                graph.penaltyPositionFactor = EditorGUILayout.FloatField("Factor", graph.penaltyPositionFactor);
                HelpBox("Applies penalty to nodes based on their Y coordinate\nSampled in Int3 space, i.e it is multiplied with Int3.Precision first (" + Int3.Precision + ")\n" +
                        "Be very careful when using negative values since a negative penalty will underflow and instead get really high");
                //GUI.enabled = preGUI;
                EditorGUI.indentLevel--;
            }

            GUI.enabled = false;
            ToggleGroup(new GUIContent("Use Texture", AstarPathEditor.AstarProTooltip), false);
            GUI.enabled            = true;
            EditorGUI.indentLevel -= 2;
        }
    }
Exemplo n.º 26
0
    public override void OnInspectorGUI()
    {
        spriteUiVisible = EditorGUILayout.Foldout(spriteUiVisible, "Sprite");
        if (spriteUiVisible)
        {
            base.OnInspectorGUI();
        }

        Init();
        if (animLibs == null)
        {
            GUILayout.Label("no libraries found");
            if (GUILayout.Button("Refresh"))
            {
                initialized = false;
                Init();
            }
        }
        else
        {
            tk2dAnimatedSprite sprite = (tk2dAnimatedSprite)target;

            EditorGUIUtility.LookLikeInspector();
            EditorGUI.indentLevel = 1;

            if (sprite.anim == null)
            {
                sprite.anim = animLibs[0].GetAsset <tk2dSpriteAnimation>();
                GUI.changed = true;
            }

            // Display animation library
            int    selAnimLib   = 0;
            string selectedGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(sprite.anim));
            for (int i = 0; i < animLibs.Length; ++i)
            {
                if (animLibs[i].assetGUID == selectedGUID)
                {
                    selAnimLib = i;
                    break;
                }
            }

            int newAnimLib = EditorGUILayout.Popup("Anim Lib", selAnimLib, animLibNames);
            if (newAnimLib != selAnimLib)
            {
                sprite.anim   = animLibs[newAnimLib].GetAsset <tk2dSpriteAnimation>();
                sprite.clipId = 0;

                if (sprite.anim.clips.Length > 0)
                {
                    // automatically switch to the first frame of the new clip
                    sprite.SwitchCollectionAndSprite(sprite.anim.clips[sprite.clipId].frames[0].spriteCollection,
                                                     sprite.anim.clips[sprite.clipId].frames[0].spriteId);
                }
            }

            // Everything else
            if (sprite.anim && sprite.anim.clips.Length > 0)
            {
                int clipId = sprite.clipId;

                // Sanity check clip id
                clipId = Mathf.Clamp(clipId, 0, sprite.anim.clips.Length - 1);
                if (clipId != sprite.clipId)
                {
                    sprite.clipId = clipId;
                    GUI.changed   = true;
                }

                string[] clipNames = new string[sprite.anim.clips.Length];
                // fill names (with ids if necessary)
                if (tk2dPreferences.inst.showIds)
                {
                    for (int i = 0; i < sprite.anim.clips.Length; ++i)
                    {
                        if (sprite.anim.clips[i].name != null && sprite.anim.clips[i].name.Length > 0)
                        {
                            clipNames[i] = sprite.anim.clips[i].name + "\t[" + i.ToString() + "]";
                        }
                        else
                        {
                            clipNames[i] = sprite.anim.clips[i].name;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < sprite.anim.clips.Length; ++i)
                    {
                        clipNames[i] = sprite.anim.clips[i].name;
                    }
                }

                int newClipId = EditorGUILayout.Popup("Clip", sprite.clipId, clipNames);
                if (newClipId != sprite.clipId)
                {
                    sprite.clipId = newClipId;
                    // automatically switch to the first frame of the new clip
                    sprite.SwitchCollectionAndSprite(sprite.anim.clips[sprite.clipId].frames[0].spriteCollection,
                                                     sprite.anim.clips[sprite.clipId].frames[0].spriteId);
                }
            }

            // Play automatically
            sprite.playAutomatically = EditorGUILayout.Toggle("Play automatically", sprite.playAutomatically);
            bool oldCreateCollider = sprite.createCollider;
            sprite.createCollider = EditorGUILayout.Toggle("Create collider", sprite.createCollider);
            if (oldCreateCollider != sprite.createCollider)
            {
                sprite.EditMode__CreateCollider();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(sprite);
            }
        }
    }
Exemplo n.º 27
0
    /// <summary>
    /// This function is called by the base editor to display normal custom inspector gui.
    /// </summary>
    protected override void CustomInspectorGUI()
    {
        base.CustomInspectorGUI();

        VisAddForceTrigger trigger = target as VisAddForceTrigger;

        if (trigger == null)
        {
            return;
        }

        trigger.controllerValue = (ControllerSourceValue)EditorGUILayout.EnumPopup("  Controller Source Value", (Enum)trigger.controllerValue);

        PropertyValueType rules = PropertyValueType.NormalRange;

        if (trigger.randomValue)
        {
            rules = PropertyValueType.RandomRange;
        }
        else if (trigger.invertValue)
        {
            rules = PropertyValueType.InvertedRange;
        }

        rules = (PropertyValueType)EditorGUILayout.EnumPopup("  Property Value Type", (Enum)rules);
        if (rules == PropertyValueType.NormalRange || rules == PropertyValueType.InvertedRange)
        {
            trigger.minControllerValue = EditorGUILayout.FloatField("    Min Controller Value", trigger.minControllerValue);
            trigger.maxControllerValue = EditorGUILayout.FloatField("    Max Controller Value", trigger.maxControllerValue);
        }
        trigger.minForceValue = EditorGUILayout.FloatField("    Min Force Value", trigger.minForceValue);
        trigger.maxForceValue = EditorGUILayout.FloatField("    Max Force Value", trigger.maxForceValue);

        if (rules == PropertyValueType.NormalRange)
        {
            trigger.invertValue = false;
            trigger.randomValue = false;
        }
        else if (rules == PropertyValueType.InvertedRange)
        {
            trigger.invertValue = true;
            trigger.randomValue = false;
        }
        else if (rules == PropertyValueType.RandomRange)
        {
            trigger.invertValue = false;
            trigger.randomValue = true;
        }

        trigger.forceMode = (ForceMode)EditorGUILayout.EnumPopup("  Force Mode", (Enum)trigger.forceMode);

#if (UNITY_2_6 || UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5)
        EditorGUIUtility.LookLikeControls();
#endif

        trigger.forceDirection = EditorGUILayout.Vector3Field("  Force Direction", trigger.forceDirection);

#if (UNITY_2_6 || UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5)
        EditorGUIUtility.LookLikeInspector();
#endif
    }
Exemplo n.º 28
0
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        //base.OnInspectorGUI();    //기본 인스페거에 오버라이딩 됨
        serializedObject.Update();

        EditorGUIUtility.LookLikeInspector();

        EnemyPattern enemyPattern = (EnemyPattern)target;

        EditorGUILayout.Space();


        #region PatternMinMaxSetting

        enemyPattern.patternSettingFold = EditorGUILayout.Foldout(enemyPattern.patternSettingFold, "Pattern Setting");
        if (enemyPattern.patternSettingFold)
        {
            ++EditorGUI.indentLevel;
            EditorGUILayout.LabelField("SpawnDelay MinMax Setting", EditorStyles.boldLabel);
            EditorGUILayout.MinMaxSlider(ref enemyPattern.spawnDelayMin, ref enemyPattern.spawnDelayMax, 0f, 50f);
            EditorGUILayout.BeginHorizontal();
            enemyPattern.spawnDelayMin = EditorGUILayout.FloatField(enemyPattern.spawnDelayMin);
            enemyPattern.spawnDelayMax = EditorGUILayout.FloatField(enemyPattern.spawnDelayMax);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            //EditorGUILayout.LabelField("Hp MinMax Setting", EditorStyles.boldLabel);
            //EditorGUILayout.BeginHorizontal();
            //enemyPattern.enemyHpMin = EditorGUILayout.IntField(enemyPattern.enemyHpMin);
            //enemyPattern.enemyHpMax = EditorGUILayout.IntField(enemyPattern.enemyHpMax);
            //EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Speed MinMax Setting", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            enemyPattern.enemySpeedMin = EditorGUILayout.FloatField(enemyPattern.enemySpeedMin);
            enemyPattern.enemySpeedMax = EditorGUILayout.FloatField(enemyPattern.enemySpeedMax);
            EditorGUILayout.EndHorizontal();


            --EditorGUI.indentLevel;
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        #endregion


        #region NodeSetting

        enemyPattern.patternLv = (EnemyPatternLevel)EditorGUILayout.EnumPopup("Pattern Level", enemyPattern.patternLv);


        EditorGUILayout.LabelField("Node Setting", EditorStyles.boldLabel);

        EditorGUILayout.BeginHorizontal();

        //노트 추가 버튼
        if (GUILayout.Button("노드 추가") == true)
        {
            enemyPattern.AddNodeNum();
        }

        //노드 지우기 버튼
        if (GUILayout.Button("노드 제거") == true)
        {
            enemyPattern.ReduceNodeNum();
        }

        EditorGUILayout.EndHorizontal();


        //NodeNum 라벨
        EditorGUILayout.LabelField("Node Count : " + enemyPattern.nodeNum);


        EditorGUILayout.Space();

        #endregion


        enemyPattern.enemyPatternFold = EditorGUILayout.Foldout(enemyPattern.enemyPatternFold, "Pattern Info");

        //enemyPatternFold = EditorGUILayout.Foldout(enemyPatternFold, "PatternInfo");

        if (enemyPattern.enemyPatternFold)
        {
            ++EditorGUI.indentLevel;
            for (int i = 0; i < enemyPattern.nodeNum; ++i)
            {
                EditorGUILayout.Space();
                enemyPattern.nodeInfoFold[i] = EditorGUILayout.Foldout(enemyPattern.nodeInfoFold[i], " Node Info " + (i + 1));


                if (enemyPattern.nodeInfoFold[i])
                {
                    ++EditorGUI.indentLevel;

                    EditorGUILayout.BeginHorizontal();

                    if (GUILayout.Button("적 하나 추가") == true)
                    {
                        enemyPattern.nodeData[i].AddEnemyNum();
                    }
                    if (GUILayout.Button("적 하나 제거") == true)
                    {
                        enemyPattern.nodeData[i].ReduceEnemyNum();
                    }

                    EditorGUILayout.EndHorizontal();


                    EditorGUILayout.BeginHorizontal();


                    float _nodeStartDelayValue = EditorGUILayout.FloatField("노드 시작 딜레이 : ", enemyPattern.nodeData[i].nodeStartDelay);
                    if (_nodeStartDelayValue != enemyPattern.nodeData[i].nodeStartDelay)
                    {
                        if (_nodeStartDelayValue < 0)
                        {
                            _nodeStartDelayValue = 0f;
                        }
                        if (_nodeStartDelayValue > 20f)
                        {
                            _nodeStartDelayValue = 20f;
                        }
                        enemyPattern.nodeData[i].nodeStartDelay = _nodeStartDelayValue;
                    }

                    int _spawnEnemyNum = EditorGUILayout.IntField("나오는 적 수 : ", enemyPattern.nodeData[i].spawnEnemyNum);

                    if (_spawnEnemyNum <= 0)
                    {
                        _spawnEnemyNum = 1;
                    }
                    if (_spawnEnemyNum != enemyPattern.nodeData[i].spawnEnemyNum)
                    {
                        enemyPattern.nodeData[i].ChangeEnemyNum(_spawnEnemyNum);
                    }


                    EditorGUILayout.EndHorizontal();


                    EditorGUILayout.Space();
                    enemyPattern.enemyInfoFold[i] = EditorGUILayout.Foldout(enemyPattern.enemyInfoFold[i], " 적 정보 " + (i + 1));


                    if (enemyPattern.enemyInfoFold[i])
                    {
                        for (int j = 0; j < enemyPattern.nodeData[i].spawnEnemyNum; ++j)
                        {
                            enemyPattern.nodeData[i].SyncVariableLength();

                            EditorGUILayout.Space();

                            ++EditorGUI.indentLevel;
                            EditorStyles.label.fontStyle = FontStyle.Bold;
                            EditorGUILayout.LabelField("※Enemy " + i + " - " + (j + 1));
                            EditorStyles.label.fontStyle = FontStyle.Normal;
                            ++EditorGUI.indentLevel;

                            enemyPattern.nodeData[i].spawnEnemyValue[j] = (EnemyValue)EditorGUILayout.EnumPopup("적 종류", enemyPattern.nodeData[i].spawnEnemyValue[j]);

                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("스폰 방향: ");
                            //Debug.Log(enemyPattern.nodeData[i].spawnDirLeft.Length);
                            //Debug.Log(j);
                            bool _isLeft = GUILayout.Toggle(enemyPattern.nodeData[i].spawnDirLeft[j], " 왼쪽");
                            if (_isLeft != enemyPattern.nodeData[i].spawnDirLeft[j])
                            {
                                enemyPattern.nodeData[i].spawnDirLeft[j]       = _isLeft;
                                enemyPattern.nodeData[i].spawnEnemy[j]._isLeft = _isLeft;
                            }
                            EditorGUILayout.EndHorizontal();


                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("스폰 딜레이: ");
                            float _spawnDelay = EditorGUILayout.Slider(enemyPattern.nodeData[i].spawnDelay[j], enemyPattern.spawnDelayMin, enemyPattern.spawnDelayMax);
                            if (_spawnDelay != enemyPattern.nodeData[i].spawnDelay[j])
                            {
                                enemyPattern.nodeData[i].spawnDelay[j] = _spawnDelay;
                            }
                            EditorGUILayout.EndHorizontal();


                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("적 속도: ");
                            float _speed = EditorGUILayout.Slider(enemyPattern.nodeData[i].spawnEnemy[j]._speed, enemyPattern.enemySpeedMin, enemyPattern.enemySpeedMax);
                            if (_speed != enemyPattern.nodeData[i].spawnEnemy[j]._speed)
                            {
                                enemyPattern.nodeData[i].spawnEnemy[j]._speed = _speed;
                            }
                            EditorGUILayout.EndHorizontal();


                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("적 체력: ");
                            int _hp = EditorGUILayout.IntSlider((int)enemyPattern.nodeData[i].spawnEnemy[j]._originHp, 1, 3);
                            if (_hp != enemyPattern.nodeData[i].spawnEnemy[j]._originHp)
                            {
                                enemyPattern.nodeData[i].spawnEnemy[j]._originHp = _hp;
                            }
                            EditorGUILayout.EndHorizontal();


                            EditorGUI.indentLevel -= 2;
                        }
                    }



                    --EditorGUI.indentLevel;
                }
            }
        }

        serializedObject.ApplyModifiedProperties();


        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(target, "EditEnemyPattern");
            EditorUtility.SetDirty(target);
        }
    }
Exemplo n.º 29
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    void OnGUI()
    {
        EditorGUI.indentLevel = 0;

        if (curEdit == null)
        {
            GUILayout.Space(10);
            GUILayout.Label("Please select an GUI Border");
            // DISABLE: this.ShowNotification( new GUIContent("Please select an Atlas Info"));
            return;
        }

        // ========================================================
        //
        // ========================================================

        Rect lastRect = new Rect(10, 0, 1, 1);

        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical(GUILayout.Width(350));

        GUILayout.Space(5);

        // get ElementInfo first
        Texture2D editTexture = exEditorHelper.LoadAssetFromGUID <Texture2D>(curEdit.textureGUID);

        lastRect = GUILayoutUtility.GetLastRect();
        EditorGUI.indentLevel = 1;

        // ========================================================
        // GUI border
        // ========================================================

        Object newBorder = EditorGUILayout.ObjectField("GUI Border"
                                                       , curEdit
                                                       , typeof(exGUIBorder)
                                                       , false
                                                       , GUILayout.Width(300)
                                                       );

        if (newBorder != curEdit)
        {
            Selection.activeObject = newBorder;
        }

        // ========================================================
        // texture field
        // ========================================================

        GUILayout.BeginHorizontal();
        GUILayout.Space(15);
        Texture2D newTexture = (Texture2D)EditorGUILayout.ObjectField(editTexture
                                                                      , typeof(Texture2D)
                                                                      , false
                                                                      , GUILayout.Height(50)
                                                                      , GUILayout.Width(50)
                                                                      );

        EditorGUIUtility.LookLikeInspector();
        if (newTexture != editTexture)
        {
            editTexture = newTexture;
            // DISABLE: some gui are good in bilinear filter (controls/window),
            //          some are good in point filter (controls/boxOver)
            // editTexture.filterMode = FilterMode.Point;
            curEdit.textureGUID = exEditorHelper.AssetToGUID(editTexture);
            // curEdit.border = new RectOffset ( 0, 0, 0, 0 ); // NOTE: we have protect below
            curEdit.editorNeedRebuild = true;
        }
        GUILayout.EndHorizontal();

        EditorGUILayout.LabelField("Name", editTexture ?  editTexture.name : "None", GUILayout.Width(200));
        EditorGUILayout.LabelField("Size", editTexture ?  editTexture.width + " x " + editTexture.height : "0 x 0 ", GUILayout.Width(200));

        // ========================================================
        // texture preview
        // ========================================================

        GUILayout.Space(10);
        lastRect = GUILayoutUtility.GetLastRect();
        TexturePreviewField(new Rect(30, lastRect.yMax, 100, 100), curEdit, editTexture);
        GUILayout.Space(10);

        // ========================================================
        // Rect Offset
        // ========================================================

        GUI.enabled = editTexture != null;
        EditorGUIUtility.LookLikeControls();
        GUILayout.BeginHorizontal();
        int newLeft = EditorGUILayout.IntField("Left", curEdit.border.left, GUILayout.Width(200));            // left

        if (editTexture)
        {
            newLeft = Mathf.Clamp(newLeft, 0, editTexture.width - curEdit.border.right);
            if (newLeft != curEdit.border.left)
            {
                curEdit.border.left       = newLeft;
                curEdit.editorNeedRebuild = true;
            }
        }

        int newRight = EditorGUILayout.IntField("Right", curEdit.border.right, GUILayout.Width(200));            // right

        if (editTexture)
        {
            newRight = Mathf.Clamp(newRight, 0, editTexture.width - curEdit.border.left);
            if (newRight != curEdit.border.right)
            {
                curEdit.border.right      = newRight;
                curEdit.editorNeedRebuild = true;
            }
        }

        GUILayout.Label(" = " + curEdit.border.horizontal);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        int newTop = EditorGUILayout.IntField("Top", curEdit.border.top, GUILayout.Width(200));            // top

        if (editTexture)
        {
            newTop = Mathf.Clamp(newTop, 0, editTexture.height - curEdit.border.bottom);
            if (newTop != curEdit.border.top)
            {
                curEdit.border.top        = newTop;
                curEdit.editorNeedRebuild = true;
            }
        }

        int newBottom = EditorGUILayout.IntField("Bottom", curEdit.border.bottom, GUILayout.Width(200));            // bottom

        if (editTexture)
        {
            newBottom = Mathf.Clamp(newBottom, 0, editTexture.height - curEdit.border.top);
            if (newBottom != curEdit.border.bottom)
            {
                curEdit.border.bottom     = newBottom;
                curEdit.editorNeedRebuild = true;
            }
        }

        GUILayout.Label(" = " + curEdit.border.vertical);
        GUILayout.EndHorizontal();
        EditorGUIUtility.LookLikeInspector();
        GUI.enabled = true;

        GUILayout.BeginHorizontal();
        GUILayout.Space(15);
        GUILayout.Label("Center = " + (editTexture ?
                                       (editTexture.width - curEdit.border.horizontal) + " x " + (editTexture.height - curEdit.border.vertical)
                              : "0 x 0"));
        GUILayout.EndHorizontal();

        // ========================================================
        // save button
        // ========================================================

        GUI.enabled = curEdit.editorNeedRebuild;
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Save", GUILayout.Width(50), GUILayout.Height(20)))
        {
            AssetDatabase.SaveAssets();
        }
        GUILayout.Space(5);
        GUILayout.EndHorizontal();
        GUI.enabled = true;

        GUILayout.EndVertical();

        GUILayout.Space(10);
        lastRect = GUILayoutUtility.GetLastRect();

        // ========================================================
        // draw vertical split line
        // ========================================================

        exEditorHelper.DrawLine(new Vector2(lastRect.xMax, 0),
                                new Vector2(lastRect.xMax, position.height),
                                Color.black,
                                1.0f);

        GUILayout.BeginVertical();

        // ========================================================
        // toolbar
        // ========================================================

        // GUILayout.BeginHorizontal ( EditorStyles.toolbar, GUILayout.MaxWidth(position.width - 350) );
        GUILayout.BeginHorizontal(EditorStyles.toolbar);

        // ========================================================
        // Show Grid
        // ========================================================

        showGrid = GUILayout.Toggle(showGrid, "Show Grid", EditorStyles.toolbarButton);

        // ========================================================
        // Preview Width and Height
        // ========================================================

        EditorGUIUtility.LookLikeControls();
        GUILayout.BeginHorizontal();
        previewWidth  = Mathf.Max(curEdit.border.horizontal, EditorGUILayout.IntField("Width", previewWidth, EditorStyles.toolbarTextField, GUILayout.Width(200)));                      // preview width
        previewHeight = Mathf.Max(curEdit.border.vertical, EditorGUILayout.IntField("Height", previewHeight, EditorStyles.toolbarTextField, GUILayout.Width(200)));                      // preview height
        GUILayout.EndHorizontal();
        EditorGUIUtility.LookLikeInspector();

        GUILayout.FlexibleSpace();

        // ========================================================
        // Reset Width & Height
        // ========================================================

        if (GUILayout.Button("Reset", EditorStyles.toolbarButton))
        {
            previewWidth  = 200;
            previewHeight = 200;
        }

        // ========================================================
        // Help
        // ========================================================

        if (GUILayout.Button(exEditorHelper.HelpTexture(), EditorStyles.toolbarButton))
        {
            Help.BrowseURL("http://www.ex-dev.com/ex2d/wiki/doku.php?id=manual:gui_border_editor");
        }

        GUILayout.EndHorizontal();

        // ========================================================
        // BorderPreviewField
        // ========================================================

        float toolbarHeight = EditorStyles.toolbar.CalcHeight(new GUIContent(""), 0);
        Rect  previewArea   = new Rect(lastRect.xMax,
                                       toolbarHeight,
                                       position.width - lastRect.xMax,
                                       position.height - toolbarHeight);

        //
        scrollPos = GUI.BeginScrollView(previewArea,
                                        scrollPos,
                                        new Rect(-10.0f,
                                                 -10.0f,
                                                 (previewArea.width - previewWidth) / 2.0f + previewWidth + 20.0f,
                                                 (previewArea.height - previewHeight) / 2.0f + previewHeight + 20.0f)
                                        );
        BorderPreviewField(new Rect((previewArea.width - previewWidth) / 2.0f,
                                    (previewArea.height - previewHeight) / 2.0f,
                                    previewWidth,
                                    previewHeight),
                           curEdit,
                           editTexture);
        GUI.EndScrollView();
        GUILayout.EndVertical();

        GUILayout.EndHorizontal();

        // ========================================================
        // dirty
        // ========================================================

        if (GUI.changed)
        {
            EditorUtility.SetDirty(curEdit);
        }
    }
Exemplo n.º 30
0
        private void DrawSettingsGUI()
        {
            EditorGUIUtility.LookLikeInspector();
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            GUILayout.Space(12);

            EditorGUI.indentLevel  = INDENT_BASE_LEVEL + 1;
            uLink.Network.sendRate = Mathf.Max(0, EditorGUILayout.FloatField("State Sync Send Rate", uLink.Network.sendRate));
            uLink.Network.isAuthoritativeServer     = EditorGUILayout.Toggle("Authoritative Server", uLink.Network.isAuthoritativeServer);
            uLink.Network.useDifferentStateForOwner = EditorGUILayout.Toggle("Different State For Owner", uLink.Network.useDifferentStateForOwner);
            uLink.Network.rpcTypeSafe = (RPCTypeSafe)EditorGUILayout.Popup("RPC Type Safe", (int)uLink.Network.rpcTypeSafe, RPCTYPESAFE_NAMES);
            EditorGUI.indentLevel     = INDENT_BASE_LEVEL;

            if (BeginFoldout(ref foldoutClient, "Client"))
            {
                uLink.Network.requireSecurityForConnecting = EditorGUILayout.Toggle("Require Security For Connecting", uLink.Network.requireSecurityForConnecting);
                uLink.Network.symmetricKeySize             = Mathf.Max(0, EditorGUILayout.IntField("AES Symmetric Key Size", uLink.Network.symmetricKeySize));

                EndFoldout();
            }

            if (BeginFoldout(ref foldoutServer, "Server"))
            {
                uLink.Network.incomingPassword = EditorGUILayout.TextField("Incoming Password", uLink.Network.incomingPassword);
                uLink.Network.useProxy         = EditorGUILayout.Toggle("Use Proxy", uLink.Network.useProxy);
                uLink.Network.useRedirect      = EditorGUILayout.Toggle("Use Redirect", uLink.Network.useRedirect);
                uLink.Network.redirectIP       = EditorGUILayout.TextField("Redirect IP/Host", uLink.Network.redirectIP);
                uLink.Network.redirectPort     = Mathf.Max(0, EditorGUILayout.IntField("Redirect Port", uLink.Network.redirectPort));

                EndFoldout();
            }

            if (BeginFoldout(ref foldoutCellServer, "Cell Server"))
            {
                uLink.Network.trackRate     = Mathf.Max(0, EditorGUILayout.FloatField("Track Rate", uLink.Network.trackRate));
                uLink.Network.trackMaxDelta = Mathf.Max(0, EditorGUILayout.FloatField("Track Max Delta", uLink.Network.trackMaxDelta));

                EndFoldout();
            }

            if (BeginFoldout(ref foldoutMasterServer, "Master Server"))
            {
                uLink.MasterServer.gameType        = EditorGUILayout.TextField("Game Type", uLink.MasterServer.gameType);
                uLink.MasterServer.gameName        = EditorGUILayout.TextField("Game Name", uLink.MasterServer.gameName);
                uLink.MasterServer.gameMode        = EditorGUILayout.TextField("Game Mode", uLink.MasterServer.gameMode);
                uLink.MasterServer.gameLevel       = EditorGUILayout.TextField("Game Level", uLink.MasterServer.gameLevel);
                uLink.MasterServer.comment         = EditorGUILayout.TextField("Comment", uLink.MasterServer.comment);
                uLink.MasterServer.dedicatedServer = EditorGUILayout.Toggle("Dedicated Server", uLink.MasterServer.dedicatedServer);
                uLink.MasterServer.updateRate      = Mathf.Max(0, EditorGUILayout.FloatField("Update Rate", uLink.MasterServer.updateRate));
                uLink.MasterServer.ipAddress       = EditorGUILayout.TextField("Master Server IP/Host", uLink.MasterServer.ipAddress);
                uLink.MasterServer.port            = Mathf.Max(0, EditorGUILayout.IntField("Master Server Port", uLink.MasterServer.port));
                uLink.MasterServer.password        = EditorGUILayout.TextField("Master Server Password", uLink.MasterServer.password);

                EndFoldout();
            }

            GUILayout.Space(12);

            EditorGUI.indentLevel     = INDENT_BASE_LEVEL + 1;
            uLink.NetworkLog.minLevel = (uLink.NetworkLogLevel)EditorGUILayout.Popup("Minimum Log Level", (int)uLink.NetworkLog.minLevel, LOGLEVEL_NAMES);
            EditorGUI.indentLevel     = INDENT_BASE_LEVEL;

            if (BeginFoldout(ref foldoutLogging, "Detailed Log Levels"))
            {
                foreach (uint flagValue in Enum.GetValues(typeof(uLink.NetworkLogFlags)))
                {
                    uLink.NetworkLogFlags flag = (uLink.NetworkLogFlags)flagValue;
                    if (flag == uLink.NetworkLogFlags.None || flag == uLink.NetworkLogFlags.All)
                    {
                        continue;
                    }

                    int curLevel = (int)uLink.NetworkLog.GetMaxLevel(flag);
                    int newLevel = EditorGUILayout.Popup(flag.ToString(), curLevel, LOGLEVEL_NAMES);
                    if (curLevel != newLevel)
                    {
                        uLink.NetworkLog.SetLevel(flag, (uLink.NetworkLogLevel)newLevel);
                    }
                }

                EndFoldout();
            }

            GUILayout.Space(12);

            {
                bool oldGUIChanged = GUI.changed;
                GUI.changed = false;

                EditorGUI.indentLevel = INDENT_BASE_LEVEL + 1;
                emulationPreset       = EditorGUILayout.Popup("Network Emulation", emulationPreset, EmulationPreset.NAMES);
                EditorGUI.indentLevel = INDENT_BASE_LEVEL;

                if (GUI.changed)
                {
                    EmulationPreset.Apply(emulationPreset);
                }
                else
                {
                    GUI.changed = oldGUIChanged;
                }
            }

            if (BeginFoldout(ref foldoutEmulation, "Detailed Emulation"))
            {
                bool oldGUIChanged = GUI.changed;
                GUI.changed = false;

                uLink.Network.emulation.maxBandwidth       = Mathf.Max(0, EditorGUILayout.FloatField(new GUIContent("Max Bandwidth", "The amount of kB allowed to be sent per second. Set to 0 for no limit."), uLink.Network.emulation.maxBandwidth));
                uLink.Network.emulation.chanceOfLoss       = Mathf.Clamp01(EditorGUILayout.FloatField(new GUIContent("Chance Of Loss", "The chance for a packet to become lost in transit. 0 means no loss. 1 means all packets are lost."), uLink.Network.emulation.chanceOfLoss));
                uLink.Network.emulation.chanceOfDuplicates = Mathf.Clamp01(EditorGUILayout.FloatField(new GUIContent("Chance Of Duplicates", "The chance for a packet to become duplicated in transit. 0 means no duplicates. 1 means all packets are duplicated."), uLink.Network.emulation.chanceOfDuplicates));
                uLink.Network.emulation.minLatency         = Mathf.Max(0, EditorGUILayout.FloatField(new GUIContent("Minimum Latency", "The minimum two-way latency in seconds of outgoing packets."), uLink.Network.emulation.minLatency));
                uLink.Network.emulation.maxLatency         = Mathf.Max(0, EditorGUILayout.FloatField(new GUIContent("Maximum Latency", "The maximum two-way latency in seconds of outgoing packets."), uLink.Network.emulation.maxLatency));

                if (GUI.changed)
                {
                    emulationPreset = EmulationPreset.Find();
                }
                else
                {
                    GUI.changed = oldGUIChanged;
                }

                EndFoldout();
            }

            GUILayout.Space(12);

            if (BeginFoldout(ref foldoutConfig, "Advanced Configuration"))
            {
                uLink.Network.config.localIP                  = EditorGUILayout.TextField("Local IP Address", uLink.Network.config.localIP);
                uLink.Network.config.sendBufferSize           = Mathf.Max(0, EditorGUILayout.IntField("Send Buffer Size", uLink.Network.config.sendBufferSize));
                uLink.Network.config.receiveBufferSize        = Mathf.Max(0, EditorGUILayout.IntField("Receive Buffer Size", uLink.Network.config.receiveBufferSize));
                uLink.Network.config.maximumTransmissionUnit  = Mathf.Max(0, EditorGUILayout.IntField("Maximum Transmission Unit", uLink.Network.config.maximumTransmissionUnit));
                uLink.Network.config.timeBetweenPings         = Mathf.Max(0, EditorGUILayout.FloatField("Time Between Pings", uLink.Network.config.timeBetweenPings));
                uLink.Network.config.timeoutDelay             = Mathf.Max(0, EditorGUILayout.FloatField("Timeout Delay", uLink.Network.config.timeoutDelay));
                uLink.Network.config.handshakeRetriesMaxCount = Mathf.Max(0, EditorGUILayout.IntField("Maximum Handshake Retries", uLink.Network.config.handshakeRetriesMaxCount));
                uLink.Network.config.handshakeRetryDelay      = Mathf.Max(0, EditorGUILayout.FloatField("Handshake Retry Delay", uLink.Network.config.handshakeRetryDelay));
                uLink.Network.config.batchSendAtEndOfFrame    = EditorGUILayout.Toggle("Batch Send At End Of Frame", uLink.Network.config.batchSendAtEndOfFrame);

                EndFoldout();
            }

            EditorGUILayout.EndScrollView();

            GUILayout.FlexibleSpace();
            Utility.HorizontalBar();
            GUILayout.Space(6);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(12);
            if (GUILayout.Button("Reset", GUILayout.Width(75), GUILayout.Height(21)))
            {
                Utility.ResetPrefs();
            }
            GUILayout.FlexibleSpace();

            EditorGUILayout.BeginVertical();
            GUILayout.Space(7);
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                GUI.enabled = false;
                GUILayout.Toggle(useAutoSave, "Auto Save");
                GUI.enabled = true;
            }
            else
            {
                bool oldGUIChanged = GUI.changed;
                GUI.changed = false;

                useAutoSave = GUILayout.Toggle(useAutoSave, "Auto Save");

                if (GUI.changed)
                {
                    EditorPrefs.SetBool("uLinkSettingsEditor.useAutoSave", useAutoSave);
                }
                else
                {
                    GUI.changed = oldGUIChanged;
                }
            }
            EditorGUILayout.EndVertical();

            GUILayout.Space(8);
            if (Utility.IsPrefsDirty())
            {
                if (GUILayout.Button("Save now", GUILayout.Width(75), GUILayout.Height(21)))
                {
                    Utility.SavePrefs();
                }
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button("Saved", GUILayout.Width(75), GUILayout.Height(21));
                GUI.enabled = true;
            }
            GUILayout.Space(8);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(12);

            if (GUI.changed)
            {
                lastAutoSaveTime = EditorApplication.timeSinceStartup;
            }
        }