public static InteractionObjectList Create()
    {
        InteractionObjectList asset = ScriptableObject.CreateInstance <InteractionObjectList>();

        AssetDatabase.CreateAsset(asset, "Assets/InteractionObjectList.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);

            if (!isPlayer)
            {
                intCharParameterID = Action.ChooseParameterGUI("Character:", parameters, intCharParameterID, ParameterType.GameObject);
                if (intCharParameterID >= 0)
                {
                    intCharConstantID    = 0;
                    interactionCharacter = null;
                }
                else
                {
                    interactionCharacter = (Char)EditorGUILayout.ObjectField("Character:", interactionCharacter, typeof(Char), true);

                    intCharConstantID    = FieldToID(interactionCharacter, intCharConstantID);
                    interactionCharacter = IDToField(interactionCharacter, intCharConstantID, false);
                }
            }
            else
            {
                interactionCharacter = AC.KickStarter.player;
            }

            handsUsed = (HandsUsed)EditorGUILayout.EnumPopup("Which hand(s) to use", handsUsed);

            //Get the asset file
            interactionList = (InteractionObjectList)EditorGUILayout.ObjectField("Interaction Object List:", interactionList, typeof(InteractionObjectList), true);

            if (interactionList)
            {
                //Create a string list for the objects in the list
                List <string> objects = new List <string>();

                int index = 0;

                if (interactionList.objectList.Count > 0)
                {
                    foreach (InteractionObjectData datas in interactionList.objectList)
                    {
                        objects.Add(datas.myObject.objectName);
                        index++;
                    }

                    string label = "Object:";

                    objectNum         = EditorGUILayout.Popup(label, objectNum, objects.ToArray());
                    interactionObject = interactionList.objectList[objectNum].myObject;
                }
            }

            AfterRunningOption();
        }
Beispiel #3
0
 void CreateNewItemList()
 {
     // There is no overwrite protection here!
     // There is No "Are you sure you want to overwrite your existing object?" if it exists.
     // This should probably get a string from the user to create a new name and pass it ...
     viewIndex             = 1;
     interactionObjectList = CreateInteractionObjectList.Create();
     if (interactionObjectList)
     {
         interactionObjectList.objectList = new List <InteractionObjectData>();
         string relPath = AssetDatabase.GetAssetPath(interactionObjectList);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Beispiel #4
0
    void OpenItemList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Interaction Object List", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            interactionObjectList = AssetDatabase.LoadAssetAtPath(relPath, typeof(InteractionObjectList)) as InteractionObjectList;
            if (interactionObjectList.objectList == null)
            {
                interactionObjectList.objectList = new List <InteractionObjectData>();
            }
            if (interactionObjectList)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);

            if (!isPlayer)
            {
                intCharParameterID = Action.ChooseParameterGUI("Character:", parameters, intCharParameterID, ParameterType.GameObject);
                if (intCharParameterID >= 0)
                {
                    intCharConstantID    = 0;
                    interactionCharacter = null;
                }
                else
                {
                    interactionCharacter = (Char)EditorGUILayout.ObjectField("Character:", interactionCharacter, typeof(Char), true);

                    intCharConstantID    = FieldToID(interactionCharacter, intCharConstantID);
                    interactionCharacter = IDToField(interactionCharacter, intCharConstantID, false);
                }
            }
            else
            {
                interactionCharacter = AC.KickStarter.player;
            }

            handsUsed = (HandsUsed)EditorGUILayout.EnumPopup("Which hand(s) to use", handsUsed);

            //Get the asset file
            interactionList = (InteractionObjectList)EditorGUILayout.ObjectField("Interaction Object List:", interactionList, typeof(InteractionObjectList), true);

            if (interactionList)
            {
                //Create a string list for the objects in the list
                List <string> objects = new List <string>();

                int index = 0;

                if (interactionList.objectList.Count > 0)
                {
                    foreach (InteractionObjectData datas in interactionList.objectList)
                    {
                        objects.Add(datas.myObject.objectName);
                        index++;
                    }

                    string label = "Object:";

                    objectNum         = EditorGUILayout.Popup(label, objectNum, objects.ToArray());
                    interactionObject = interactionList.objectList[objectNum].myObject;
                }
            }

            if (interactionCharacter != null)
            {
                animator = interactionCharacter.GetComponent <Animator>();
                //Create a string list for the trigger parameters
                List <string> triggerList = new List <string>();

                int i = 0;

                if (animator.parameterCount > 0)
                {
                    foreach (AnimatorControllerParameter parameter in animator.parameters)
                    {
                        triggerList.Add(parameter.name);

                        //If the trigger has been removed for some reason, make sure the variable is still valid
                        if (parameter.nameHash == animatorID)
                        {
                            animatorNum = i;
                        }

                        i++;
                    }

                    if (animatorNum == -1)
                    {
                        Debug.Log("Previously chosen trigger parameter no longer exists!");
                        animatorNum = 0;
                        animatorID  = 0;
                    }

                    string label = "Trigger:";

                    animatorNum = EditorGUILayout.Popup(label, animatorNum, triggerList.ToArray());
                    animatorID  = animator.parameters[animatorNum].nameHash;
                    trigger     = animator.parameters[animatorNum];
                }
            }


            AfterRunningOption();
        }
Beispiel #6
0
    /*void OnEnable()
     * {
     *  if (EditorPrefs.HasKey("ObjectPath"))
     *  {
     *      string objectPath = EditorPrefs.GetString("ObjectPath");
     *      interactionObjectList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(InteractionObjectList)) as InteractionObjectList;
     *  }
     *
     * }*/

    void OnGUI()
    {
        GUILayout.BeginVertical();
        GUILayout.Label("Inventory Object Editor", EditorStyles.largeLabel);

        interactionObjectList = EditorGUILayout.ObjectField("Object List:", interactionObjectList, typeof(InteractionObjectList), true) as InteractionObjectList;
        GUILayout.EndVertical();

        GUILayout.BeginHorizontal();

        if (interactionObjectList)
        {
            if (GUILayout.Button("Show Object List"))
            {
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = interactionObjectList;
            }
        }
        if (GUILayout.Button("Open Object List"))
        {
            OpenItemList();
        }

        GUILayout.EndHorizontal();


        if (interactionObjectList == null)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            if (GUILayout.Button("Create New Object List", GUILayout.ExpandWidth(false)))
            {
                CreateNewItemList();
            }
            if (GUILayout.Button("Open Existing Object List", GUILayout.ExpandWidth(false)))
            {
                OpenItemList();
            }
            GUILayout.EndHorizontal();
        }

        GUILayout.Space(20);

        if (interactionObjectList)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Space(10);

            if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false)))
            {
                if (viewIndex > 1)
                {
                    viewIndex--;
                }
            }
            GUILayout.Space(5);
            if (GUILayout.Button("Next", GUILayout.ExpandWidth(false)))
            {
                if (viewIndex < interactionObjectList.objectList.Count)
                {
                    viewIndex++;
                }
            }

            GUILayout.Space(60);

            if (GUILayout.Button("Add Object", GUILayout.ExpandWidth(false)))
            {
                AddItem();
            }
            if (GUILayout.Button("Delete Object", GUILayout.ExpandWidth(false)))
            {
                DeleteItem(viewIndex - 1);
            }

            GUILayout.EndHorizontal();

            if (interactionObjectList.objectList == null)
            {
                return;
            }
            //Debug.Log("wtf");

            if (interactionObjectList.objectList.Count > 0)
            {
                GUILayout.BeginHorizontal();
                viewIndex = Mathf.Clamp(EditorGUILayout.IntField("Current Object:", viewIndex, GUILayout.ExpandWidth(false)), 1, interactionObjectList.objectList.Count);

                EditorGUILayout.LabelField("of   " + interactionObjectList.objectList.Count.ToString() + "  items", "", GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();

                interactionObjectList.objectList[viewIndex - 1] = EditorGUILayout.ObjectField("Object Data:", interactionObjectList.objectList[viewIndex - 1], typeof(InteractionObjectData), true) as InteractionObjectData;

                InteractionObjectData dataStuff = interactionObjectList.objectList[viewIndex - 1];

                if (dataStuff.myObject)
                {
                    GUILayout.Space(10);
                    EditorGUILayout.Separator();
                    GUILayout.Space(10);

                    EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                    GUILayout.BeginVertical("Box");
                    GUILayout.Label(dataStuff.myObject.objectName, EditorStyles.boldLabel);
                    EditorGUILayout.ObjectField("Parent Object:", dataStuff.myObject.objectParent, typeof(Transform), true);
                    EditorGUILayout.ObjectField("Right Hold Position:", dataStuff.myObject.rHandPosition, typeof(Transform), true);
                    EditorGUILayout.ObjectField("Left Hold Position:", dataStuff.myObject.lHandPosition, typeof(Transform), true);
                    EditorGUILayout.ObjectField("Drop Position:", dataStuff.myObject.dropPosition, typeof(Transform), true);
                    EditorGUILayout.ObjectField("Right Target:", dataStuff.myObject.rHandTarget, typeof(Transform), true);
                    EditorGUILayout.ObjectField("Left Target:", dataStuff.myObject.lHandTarget, typeof(Transform), true);
                    EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
                    GUILayout.Label("Sound FX", EditorStyles.boldLabel);
                    EditorGUILayout.ObjectField("Pick Up Sound:", dataStuff.myObject.pickUpSound, typeof(AudioClip), true);
                    EditorGUILayout.ObjectField("Drop Sound:", dataStuff.myObject.dropSound, typeof(AudioClip), true);
                    EditorGUILayout.ObjectField("Interaction Sound:", dataStuff.myObject.interactSound, typeof(AudioClip), true);
                    EditorGUILayout.ObjectField("Inventory Sound:", dataStuff.myObject.inventorySound, typeof(AudioClip), true);

                    GUILayout.Label("Inventory Properties", EditorStyles.boldLabel);
                    if (dataStuff.myObject.isInventoryItem)
                    {
                        GUILayout.Label("This is an inventory item.", EditorStyles.miniBoldLabel);
                        GUILayout.Label("Inventory Item: " + AC.KickStarter.inventoryManager.items[dataStuff.myObject.invID].label, EditorStyles.miniBoldLabel);
                        EditorGUILayout.ObjectField("Prefab Reference:", AC.KickStarter.inventoryManager.items[dataStuff.myObject.invID].linkedPrefab, typeof(GameObject), true);
                    }
                    else
                    {
                        GUILayout.Label("This is not an inventory item.", EditorStyles.miniBoldLabel);
                    }

                    GUILayout.EndVertical();
                }
            }
            else
            {
                GUILayout.Label("This Object List is Empty.");
                return;
            }
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(interactionObjectList);
        }
    }