Exemplo n.º 1
0
    public static void AddAction(string className, int i, ActionListAsset _target)
    {
        List <int> idArray = new List <int>();

        foreach (AC.Action _action in _target.actions)
        {
            idArray.Add(_action.id);
        }

        idArray.Sort();

        AC.Action newAction = (AC.Action)CreateInstance(className);
        newAction.hideFlags = HideFlags.HideInHierarchy;

        // Update id based on array
        foreach (int _id in idArray.ToArray())
        {
            if (newAction.id == _id)
            {
                newAction.id++;
            }
        }

        newAction.name = newAction.title;

        _target.actions.Insert(i, newAction);
        AssetDatabase.AddObjectToAsset(newAction, _target);
        AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newAction));
        AssetDatabase.Refresh();
    }
Exemplo n.º 2
0
    public static Action RebuildAction(AC.Action action, int typeIndex, ActionListAsset _target, ResultAction _resultAction, int _skipAction, ActionListAsset _linkedAsset, Cutscene _linkedCutscene)
    {
        ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

        if (actionsManager)
        {
            ActionListAssetEditor.DeleteAction(action, _target);

            string className = actionsManager.AllActions [typeIndex].fileName;

            AC.Action newAction = (AC.Action)CreateInstance(className);
            newAction.hideFlags = HideFlags.HideInHierarchy;

            newAction.endAction      = _resultAction;
            newAction.skipAction     = _skipAction;
            newAction.linkedAsset    = _linkedAsset;
            newAction.linkedCutscene = _linkedCutscene;

            AssetDatabase.AddObjectToAsset(newAction, _target);
            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newAction));
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            return(newAction);
        }

        return(action);
    }
Exemplo n.º 3
0
    private void ActionSideMenu(AC.Action action)
    {
        ActionListAsset _target = (ActionListAsset)target;

        int i = _target.actions.IndexOf(action);

        actionToAffect = action;
        GenericMenu menu = new GenericMenu();

        if (action.isEnabled)
        {
            menu.AddItem(new GUIContent("Disable"), false, Callback, "Disable");
        }
        else
        {
            menu.AddItem(new GUIContent("Enable"), false, Callback, "Enable");
        }
        menu.AddSeparator("");
        if (_target.actions.Count > 1)
        {
            menu.AddItem(new GUIContent("Cut"), false, Callback, "Cut");
        }
        menu.AddItem(new GUIContent("Copy"), false, Callback, "Copy");
        if (AdvGame.copiedActions.Count > 0)
        {
            menu.AddItem(new GUIContent("Paste after"), false, Callback, "Paste after");
        }
        menu.AddSeparator("");
        menu.AddItem(new GUIContent("Insert after"), false, Callback, "Insert after");
        menu.AddItem(new GUIContent("Delete"), false, Callback, "Delete");
        if (i > 0 || i < _target.actions.Count - 1)
        {
            menu.AddSeparator("");
        }
        if (i > 0)
        {
            menu.AddItem(new GUIContent("Re-arrange/Move to top"), false, Callback, "Move to top");
            menu.AddItem(new GUIContent("Re-arrange/Move up"), false, Callback, "Move up");
        }
        if (i < _target.actions.Count - 1)
        {
            menu.AddItem(new GUIContent("Re-arrange/Move down"), false, Callback, "Move down");
            menu.AddItem(new GUIContent("Re-arrange/Move to bottom"), false, Callback, "Move to bottom");
        }

        menu.ShowAsContext();
    }
	private void ActionSideMenu (AC.Action action)
	{
		ActionListAsset _target = (ActionListAsset) target;
		
		int i = _target.actions.IndexOf (action);
		actionToAffect = action;
		GenericMenu menu = new GenericMenu ();
		
		if (action.isEnabled)
		{
			menu.AddItem (new GUIContent ("Disable"), false, Callback, "Disable");
		}
		else
		{
			menu.AddItem (new GUIContent ("Enable"), false, Callback, "Enable");
		}
		menu.AddSeparator ("");
		if (_target.actions.Count > 1)
		{
			menu.AddItem (new GUIContent ("Cut"), false, Callback, "Cut");
		}
		menu.AddItem (new GUIContent ("Copy"), false, Callback, "Copy");
		if (AdvGame.copiedActions.Count > 0)
		{
			menu.AddItem (new GUIContent ("Paste after"), false, Callback, "Paste after");
		}
		menu.AddSeparator ("");
		menu.AddItem (new GUIContent ("Insert after"), false, Callback, "Insert after");
		menu.AddItem (new GUIContent ("Delete"), false, Callback, "Delete");
		if (i > 0 || i < _target.actions.Count-1)
		{
			menu.AddSeparator ("");
		}
		if (i > 0)
		{
			menu.AddItem (new GUIContent ("Re-arrange/Move to top"), false, Callback, "Move to top");
			menu.AddItem (new GUIContent ("Re-arrange/Move up"), false, Callback, "Move up");
		}
		if (i < _target.actions.Count-1)
		{
			menu.AddItem (new GUIContent ("Re-arrange/Move down"), false, Callback, "Move down");
			menu.AddItem (new GUIContent ("Re-arrange/Move to bottom"), false, Callback, "Move to bottom");
		}
		
		menu.ShowAsContext ();
	}
Exemplo n.º 5
0
    public static void ModifyAction(ActionListAsset _target, AC.Action _action, string callback)
    {
        ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

        if (actionsManager == null)
        {
            return;
        }

        int i = -1;

        if (_action != null && _target.actions.IndexOf(_action) > -1)
        {
            i = _target.actions.IndexOf(_action);
        }

        switch (callback)
        {
        case "Enable":
            Undo.RecordObject(_target, "Enable action");
            _target.actions [i].isEnabled = true;
            break;

        case "Disable":
            Undo.RecordObject(_target, "Disable action");
            _target.actions [i].isEnabled = false;
            break;

        case "Cut":
            Undo.RecordObject(_target, "Cut action");
            List <AC.Action> cutList   = new List <AC.Action>();
            AC.Action        cutAction = Object.Instantiate(_action) as AC.Action;
            cutList.Add(cutAction);
            AdvGame.copiedActions = cutList;
            _target.actions.Remove(_action);
            UnityEngine.Object.DestroyImmediate(_action, true);
            AssetDatabase.SaveAssets();
            break;

        case "Copy":
            List <AC.Action> copyList   = new List <AC.Action>();
            AC.Action        copyAction = Object.Instantiate(_action) as AC.Action;
            copyAction.name = copyAction.name.Replace("(Clone)", "");
            copyList.Add(copyAction);
            AdvGame.copiedActions = copyList;
            break;

        case "Paste after":
            Undo.RecordObject(_target, "Paste actions");
            List <AC.Action> pasteList = AdvGame.copiedActions;
            int j = i + 1;
            foreach (AC.Action action in pasteList)
            {
                AC.Action pastedAction = Object.Instantiate(action) as AC.Action;
                pastedAction.name      = pastedAction.name.Replace("(Clone)", "");
                pastedAction.hideFlags = HideFlags.HideInHierarchy;
                _target.actions.Insert(j, pastedAction);
                j++;
                AssetDatabase.AddObjectToAsset(pastedAction, _target);
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(pastedAction));
            }
            AssetDatabase.SaveAssets();
            break;

        case "Insert after":
            Undo.RecordObject(_target, "Create action");
            ActionListAssetEditor.AddAction(actionsManager.GetDefaultAction(), i + 1, _target);
            break;

        case "Delete":
            Undo.RecordObject(_target, "Delete action");
            _target.actions.Remove(_action);
            UnityEngine.Object.DestroyImmediate(_action, true);
            AssetDatabase.SaveAssets();
            break;

        case "Move to top":
            Undo.RecordObject(_target, "Move action to top");
            _target.actions.Remove(_action);
            _target.actions.Insert(0, _action);
            break;

        case "Move up":
            Undo.RecordObject(_target, "Move action up");
            _target.actions.Remove(_action);
            _target.actions.Insert(i - 1, _action);
            break;

        case "Move to bottom":
            Undo.RecordObject(_target, "Move action to bottom");
            _target.actions.Remove(_action);
            _target.actions.Insert(_target.actions.Count, _action);
            break;

        case "Move down":
            Undo.RecordObject(_target, "Move action down");
            _target.actions.Remove(_action);
            _target.actions.Insert(i + 1, _action);
            break;
        }
    }
Exemplo n.º 6
0
 public static void DeleteAction(AC.Action action, ActionListAsset _target)
 {
     UnityEngine.Object.DestroyImmediate(action, true);
     AssetDatabase.SaveAssets();
     _target.actions.Remove(action);
 }