コード例 #1
0
    void DrawPrefabInfo(AscensionEntity entity)
    {
        PrefabType prefabType = PrefabUtility.GetPrefabType(entity.gameObject);

#if DEBUG
        EditorGUILayout.LabelField("Type", prefabType.ToString());
        EditorGUILayout.LabelField("Scene Id", entity.SceneGuid.ToString());
#endif

        switch (prefabType)
        {
        case PrefabType.Prefab:
        case PrefabType.PrefabInstance:
            EditorGUILayout.LabelField("Id", entity.prefabId.ToString());

            if (entity.prefabId < 0)
            {
                EditorGUILayout.HelpBox("Prefab id not set, run the 'Ascension/Emit Code' menu option to correct", MessageType.Error);
            }

            if (prefabType == PrefabType.Prefab)
            {
                if (PrefabDatabase.Contains(entity) == false)
                {
                    EditorGUILayout.HelpBox("Prefab lookup not valid, run the 'Ascension/Emit Code' menu option to correct", MessageType.Error);
                }
            }
            break;

        case PrefabType.None:
            if (entity.prefabId != 0)
            {
                // force 0 prefab id
                entity.prefabId = 0;

                // set dirty
                EditorUtility.SetDirty(this);
            }

            DEditorGUI.Disabled(() =>
            {
                EditorGUILayout.IntField("Prefab Id", entity.prefabId);
            });

            break;

        case PrefabType.DisconnectedPrefabInstance:
            entity.prefabId = EditorGUILayout.IntField("Prefab Id", entity.prefabId);

            if (entity.prefabId < 0)
            {
                EditorGUILayout.HelpBox("Prefab Id not set", MessageType.Error);
            }
            break;
        }
    }
コード例 #2
0
    public void OnInspectorGUI2()
    {
        //GUILayout.Space(4);

        //GUILayout.BeginHorizontal();
        //GUILayout.Space(2);
        //GUI.DrawTexture(GUILayoutUtility.GetRect(128, 128, 64, 64, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)), Resources.Load("AscensionLogo") as Texture2D);
        //GUILayout.EndHorizontal();

        GUILayout.Space(2);

        EditorGUI.BeginDisabledGroup(Application.isPlaying);

        AscensionEntity entity     = (AscensionEntity)target;
        PrefabType      prefabType = PrefabUtility.GetPrefabType(entity.gameObject);

        RuntimeSettings settings = RuntimeSettings.Instance;

#if DEBUG
        EditorGUILayout.LabelField("Prefab Type", prefabType.ToString());
#endif

        // Prefab Id
        switch (prefabType)
        {
        case PrefabType.Prefab:
        case PrefabType.PrefabInstance:
            EditorGUILayout.LabelField("Prefab Id", entity.PrefabId.ToString());

            if (entity.prefabId < 0)
            {
                EditorGUILayout.HelpBox("Prefab id not set, run the 'Ascension/Emit Code' menu option to correct", MessageType.Error);
            }

            if (prefabType == PrefabType.Prefab)
            {
                if (PrefabDatabase.Contains(entity) == false)
                {
                    EditorGUILayout.HelpBox("Prefab lookup not valid, run the 'Ascension/Emit Code' menu option to correct", MessageType.Error);
                }
            }
            break;

        case PrefabType.None:
            if (entity.prefabId != 0)
            {
                // force 0 prefab id
                entity.prefabId = 0;

                // set dirty
                EditorUtility.SetDirty(this);
            }

            DEditorGUI.Disabled(() =>
            {
                EditorGUILayout.IntField("Prefab Id", entity.prefabId);
            });

            break;

        case PrefabType.DisconnectedPrefabInstance:
            entity.prefabId = EditorGUILayout.IntField("Prefab Id", entity.prefabId);

            if (entity.prefabId < 0)
            {
                EditorGUILayout.HelpBox("Prefab Id not set", MessageType.Error);
            }
            break;
        }

        EditState(entity);
        EditProperties(entity);
        EditSceneProperties(entity, prefabType);

        EditorGUI.EndDisabledGroup();

        if (prefabType == PrefabType.Prefab)
        {
            SaveEntity(entity);
        }
        else
        {
            if (Application.isPlaying)
            {
                RuntimeInfoGUI(entity);
            }
            else
            {
                SaveEntity(entity);
            }
        }
    }