Пример #1
0
 protected override void DrawWidgetFooter(ScriptForgeStyles style)
 {
     if (GUILayout.Button("Documentation", style.button))
     {
         ScriptableForge.OpenDocumentation();
     }
 }
Пример #2
0
 public void Initalize(ScriptableForge instance)
 {
     m_ScriptableForge     = instance;
     m_BackgroundColor     = Color.white;
     m_OpenAnimation.value = m_IsOpen;
     m_OpenAnimation.valueChanged.AddListener(m_ScriptableForge.Repaint);
     m_ScriptableForge.Repaint();
 }
Пример #3
0
 public void Initalize(ScriptableForge instance)
 {
     m_ScriptableForge     = instance;
     m_BackgroundColor     = Color.white;
     m_OpenAnimation.value = m_IsOpen;
     m_ScriptableForge.Repaint();
     m_InDevelopment = Attribute.GetCustomAttribute(GetType(), typeof(InDevelopmentAttribute)) != null;
 }
        private static void Initialize()
        {
            var instance = GetInstance();

            if (instance == null)
            {
                Debug.Log("Unable to load or create Scriptable Forge instance");
            }

            if (!EditorPrefs.HasKey(FIRST_LAUNCH_KEY))
            {
                EditorPrefs.SetBool(FIRST_LAUNCH_KEY, true);
                ScriptableForge.OpenDocumentation();
            }
        }
 private void OnEnable()
 {
     m_Target = target as ScriptableForge;
 }
Пример #6
0
        /// <summary>
        /// Reads the yaml defined on disk if there is one for a Scriptable Forge or
        /// creates a new one.
        /// </summary>
        private static void ReadInstanceFromDiskOrCreateNew()
        {
            // Store our path
            string savePath = GetSavePath();

            ScriptableForge m_Instance      = null;
            List <Widget>   m_LoadedWidgets = new List <Widget>();

            // Does it exist already?
            if (File.Exists(savePath))
            {
                // It does so lets load it
                Object[] loadedObject = InternalEditorUtility.LoadSerializedFileAndForget(savePath);

                // Loop over all our objects and find the one we care about (There should really only be one)
                for (int i = 0; i < loadedObject.Length; i++)
                {
                    if (loadedObject[i] is ScriptableForge)
                    {
                        // Save our instance
                        m_Instance = loadedObject[i] as ScriptableForge;
                    }
                    else
                    {
                        if (loadedObject[i] is Widget)
                        {
                            m_LoadedWidgets.Add(loadedObject[i] as Widget);
                        }
                    }
                }
            }
            else
            {
                // We don't have a save file so we create a new one.
                m_Instance = CreateInstance <ScriptableForge>();
            }

            // Initialize all the widgets.
            for (int i = 0; i < m_LoadedWidgets.Count; i++)
            {
                m_LoadedWidgets[i].Initalize(m_Instance);
            }

            // Sort them in order.
            m_LoadedWidgets.Sort();

            // Save them back to our instance.
            m_Instance.Widgets = m_LoadedWidgets;

            // Regenerate Widgets if they are set to auto build.
            for (int i = 0; i < m_LoadedWidgets.Count; i++)
            {
                m_LoadedWidgets[i].OnLoaded();
            }

            // Get all our widget types.
            List <Type> widgetTypes = GetDefinedWidgetTypes(includeAbstractTypes: false);

            // Remove all that are not required.
            for (int i = widgetTypes.Count - 1; i >= 0; i--)
            {
                if (Attribute.GetCustomAttribute(widgetTypes[i], typeof(RequiredWidgetAttribute)) != null)
                {
                    bool foundWidget = false;
                    for (int x = 0; x < m_LoadedWidgets.Count; x++)
                    {
                        if (m_LoadedWidgets[x].GetType() == widgetTypes[i])
                        {
                            foundWidget = true;
                            // We found the type so we move on.
                            break;
                        }
                    }
                    if (!foundWidget)
                    {
                        m_Instance.OnWidgetAdded(widgetTypes[i]);
                    }
                }
            }
        }