Example #1
0
        public void OnEnable()
        {
            if (!NeedsReenable())
            {
                return;
            }

            showBaseEditor = false;
            _umaData       = target as UMAData;
            _errorMessage  = null;
            _recipe        = _umaData.umaRecipe;
            if (_recipe == null || _recipe.raceData == null)
            {
                _errorMessage = "UMA Data not loaded.";
            }
            else
            {
                DNAMasterEditor.umaGenerator = _umaData.umaGenerator;
                dnaEditor  = new DNAMasterEditor(_recipe);
                slotEditor = new SlotMasterEditor(_recipe);

                SetCurrentDnaTypeHashes();

                _rebuildOnLayout = true;
            }
        }
Example #2
0
        public void OnEnable()
        {
            if (!NeedsReenable())
            {
                return;
            }

            _errorMessage  = null;
            _recipe        = new UMAData.UMARecipe();
            showBaseEditor = false;

            try
            {
                var umaRecipeBase = target as UMARecipeBase;
                if (umaRecipeBase != null)
                {
                    umaRecipeBase.Load(_recipe, UMAContext.FindInstance());
                    _description = umaRecipeBase.GetInfo();
                }
            }
            catch (UMAResourceNotFoundException e)
            {
                _errorMessage = e.Message;
            }

            dnaEditor  = new DNAMasterEditor(_recipe);
            slotEditor = new SlotMasterEditor(_recipe);

            _rebuildOnLayout = true;
        }
Example #3
0
 protected virtual void Rebuild()
 {
     _rebuildOnLayout = false;
     if (_recipe != null)
     {
         dnaEditor  = new DNAMasterEditor(_recipe);
         slotEditor = new SlotMasterEditor(_recipe);
     }
 }
Example #4
0
 public override void OnInspectorGUI()
 {
     if (dnaEditor != null)
     {
         if (!CheckCurrentDNATypeHashes())
         {
             dnaEditor = new DNAMasterEditor(_recipe);
             SetCurrentDnaTypeHashes();
         }
     }
     base.OnInspectorGUI();
 }
Example #5
0
        public void OnEnable()
        {
            if (!NeedsReenable())
            {
                return;
            }

            _errorMessage  = null;
            _recipe        = new UMAData.UMARecipe();
            showBaseEditor = false;

            try
            {
                var umaRecipeBase = target as UMARecipeBase;
                if (umaRecipeBase != null)
                {
                    var context = UMAContext.FindInstance();
                    //create a virtual UMAContext if we dont have one and we have DCS
                    if (context == null || context.gameObject.name == "UMAEditorContext")
                    {
                        context          = umaRecipeBase.CreateEditorContext();               //will create or update an UMAEditorContext to the latest version
                        generatedContext = context.gameObject.transform.parent.gameObject;    //The UMAContext in a UMAEditorContext is that gameobject's child
                    }
                    //legacy checks for context
                    if (context == null)
                    {
                        _errorMessage = "Editing a recipe requires a loaded scene with a valid UMAContext.";
                        Debug.LogWarning(_errorMessage);
                        //_recipe = null;
                        //return;
                    }
                    else if (context.raceLibrary == null)
                    {
                        _errorMessage = "Editing a recipe requires a loaded scene with a valid UMAContext with RaceLibrary assigned.";
                        Debug.LogWarning(_errorMessage);
                        //_recipe = null;
                        //return;
                    }
                    umaRecipeBase.Load(_recipe, context);
                    _description = umaRecipeBase.GetInfo();
                }
            }
            catch (UMAResourceNotFoundException e)
            {
                _errorMessage = e.Message;
            }

            dnaEditor  = new DNAMasterEditor(_recipe);
            slotEditor = new SlotMasterEditor(_recipe);

            _rebuildOnLayout = true;
        }
Example #6
0
 protected virtual void Rebuild()
 {
     _rebuildOnLayout = false;
     if (_recipe != null)
     {
         int oldViewDNA = dnaEditor.viewDna;
         UMAData.UMARecipe oldRecipe = dnaEditor.recipe;
         dnaEditor = new DNAMasterEditor(_recipe);
         if (oldRecipe == _recipe)
         {
             dnaEditor.viewDna = oldViewDNA;
         }
         slotEditor = new SlotMasterEditor(_recipe);
     }
 }
Example #7
0
        public void OnEnable()
        {
            if (!NeedsReenable())
            {
                return;
            }

            showBaseEditor = true;
            _umaData       = target as UMAData;
            _errorMessage  = null;
            _recipe        = _umaData.umaRecipe;
            if (_recipe == null)
            {
                _errorMessage = "UMA Data not loaded.";
            }
            else
            {
                dnaEditor  = new DNAMasterEditor(_recipe);
                slotEditor = new SlotMasterEditor(_recipe);

                _rebuildOnLayout = true;
            }
        }
Example #8
0
        public void OnEnable()
        {
            if (!NeedsReenable())
            {
                return;
            }

            _errorMessage  = null;
            _recipe        = new UMAData.UMARecipe();
            showBaseEditor = false;

            try
            {
                var umaRecipeBase = target as UMARecipeBase;
                if (umaRecipeBase != null)
                {
                    //if we dont have an umaContext the recipe wont actually load and we dont want people to edit it because it wont save properly
                    //01022016 BUT we do still ned to output the inspector or else people cant make new recipes when they have a scene open with no UMAContext
                    //TODO work out a way of editing recipes when there ISNT an UMA Context
                    var context = UMAContext.FindInstance();
                    if (context == null)
                    {
                        context          = umaRecipeBase.CreateEditorContext();
                        generatedContext = context.gameObject;
                    }
                    if (context == null)
                    {
                        context       = umaRecipeBase.CreateEditorContext();
                        _errorMessage = "Editing a recipe requires a loaded scene with a valid UMAContext.";
                        Debug.LogWarning(_errorMessage);
                        //_recipe = null;
                        //return;
                    }
                    else if (context.raceLibrary == null)
                    {
                        _errorMessage = "Editing a recipe requires a loaded scene with a valid UMAContext with RaceLibrary assigned.";
                        Debug.LogWarning(_errorMessage);
                        //_recipe = null;
                        //return;
                    }
                    //when the recipe loads it can be really slow the first time can we show a notification?
                    //this doesn't bloody show quick enough though
                    //var editorAssembly = typeof(Editor).Assembly;
                    //var inspectorWindowType = editorAssembly.GetType("UnityEditor.InspectorWindow");
                    //inspectorWindow = EditorWindow.GetWindow(inspectorWindowType);
                    //if(inspectorWindow != null)
                    //inspectorWindow.ShowNotification(new GUIContent("UMA is gathering Data.."));
                    //this is where we are waiting, but the notification does not show before this starts
                    umaRecipeBase.Load(_recipe, context);
                    _description = umaRecipeBase.GetInfo();

                    //if (inspectorWindow != null)
                    //	inspectorWindow.RemoveNotification();
                }
            }
            catch (UMAResourceNotFoundException e)
            {
                _errorMessage = e.Message;
            }

            dnaEditor  = new DNAMasterEditor(_recipe);
            slotEditor = new SlotMasterEditor(_recipe);

            _rebuildOnLayout = true;
        }