public static Action RebuildAction(AC.Action action, int typeIndex, ActionListAsset _target)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager)
            {
                bool   _showComment       = action.showComment;
                bool   _showOutputSockets = action.showOutputSockets;
                string _comment           = action.comment;

                ActionListAssetEditor.DeleteAction(action, _target);

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

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

                newAction.showComment       = _showComment;
                newAction.comment           = _comment;
                newAction.showOutputSockets = _showOutputSockets;

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

                return(newAction);
            }

            return(action);
        }
        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);
        }
        public static void ResetList(ActionListAsset _targetAsset)
        {
            if (_targetAsset.actions.Count == 0 || (_targetAsset.actions.Count == 1 && _targetAsset.actions[0] == null))
            {
                if (_targetAsset.actions.Count == 1)
                {
                    ActionListAssetEditor.DeleteAction(_targetAsset.actions[0], _targetAsset);
                }
                Action newAction = ActionList.GetDefaultAction();
                _targetAsset.actions.Add(newAction);
                newAction.hideFlags = HideFlags.HideInHierarchy;

                AssetDatabase.AddObjectToAsset(newAction, _targetAsset);
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newAction));
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }
Example #4
0
        public static Action RebuildAction(AC.Action action, int typeIndex, ActionListAsset _target, int insertIndex = -1, ActionEnd _end = null)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager)
            {
                bool   _showComment       = action.showComment;
                bool   _showOutputSockets = action.showOutputSockets;
                string _comment           = action.comment;

                ActionListAssetEditor.DeleteAction(action, _target);

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

                AC.Action newAction = (AC.Action)CreateInstance(className);
                newAction.name = className;

                if (_end != null)
                {
                    newAction.endAction      = _end.resultAction;
                    newAction.skipAction     = _end.skipAction;
                    newAction.linkedAsset    = _end.linkedAsset;
                    newAction.linkedCutscene = _end.linkedCutscene;
                }

                newAction.showComment       = _showComment;
                newAction.comment           = _comment;
                newAction.showOutputSockets = _showOutputSockets;

                if (insertIndex >= 0)
                {
                    _target.actions.Insert(insertIndex, newAction);
                }

                SyncAssetObjects(_target);

                return(newAction);
            }

            return(action);
        }