Ejemplo n.º 1
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            string      text  = System.IO.File.ReadAllText(ctx.assetPath);
            SetterAsset asset = ScriptableObject.CreateInstance <SetterAsset>();

            asset.m_XML = text;
            Serializer.Deserialize(asset, text);
            ctx.AddObjectToAsset("MainAsset", asset);
            ctx.SetMainObject(asset);
            SetterAssetCache.SetDirty();
        }
Ejemplo n.º 2
0
        void AddMenu()
        {
            GenericMenu menu = new GenericMenu();

            foreach (var type in Util.ContextTypes)
            {
                menu.AddItem(new GUIContent(type.Name), false, () =>
                {
                    var ctx = System.Activator.CreateInstance(type) as SetterContext;
                    m_Asset.m_Contexts.Add(ctx);
                    SetterAssetCache.SetDirty();
                });
            }
            menu.ShowAsContext();
        }
Ejemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            GUI.enabled = true;
            using (new GUILayout.HorizontalScope())
            {
                if (GUILayout.Button("戻す", GUILayout.ExpandWidth(false), GUILayout.MinWidth(100)))
                {
                    m_Asset.Load();
                    SetterAssetCache.SetDirty();
                }
                if (GUILayout.Button("保存", GUILayout.ExpandWidth(false), GUILayout.MinWidth(100)))
                {
                    m_Asset.Save();
                    SetterAssetCache.SetDirty();
                }
                if (GUILayout.Button("追加", GUILayout.ExpandWidth(false), GUILayout.MinWidth(100)))
                {
                    AddMenu();
                }
            }

            for (int i = 0; i < m_Asset.m_Contexts.Count; i++)
            {
                using (new GUILayout.VerticalScope("box", GUILayout.MinHeight(100f)))
                {
                    var ctx  = m_Asset.m_Contexts[i];
                    var path = AssetDatabase.GetAssetPath(m_Asset);
                    var dir  = path.Substring(0, path.LastIndexOf('/'));
                    ctx.SetDirectory(dir);
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(ctx.GetType().Name);
                        if (GUILayout.Button("削除", GUILayout.ExpandWidth(false)))
                        {
                            m_Asset.m_Contexts.Remove(ctx);
                            break;
                        }
                    }
                    GUILayout.Label(ctx.Description);
                    ctx.OnGUI();
                }
            }
        }