Exemple #1
0
 protected override void OnValidate()
 {
     base.OnValidate();
     this.Set(this.m_IsOn, false);
     this.PlayEffect(this.toggleTransition == ToggleExtended.ToggleTransition.None);
     UnityEditor.PrefabType prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);
     if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying)
     {
         CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
     }
 }
    bool IsPrefab()
    {
        bool isPrefab = false;

#if UNITY_EDITOR
        UnityEditor.PrefabType type = UnityEditor.PrefabUtility.GetPrefabType(gameObject);
        isPrefab = type != UnityEditor.PrefabType.None &&
                   type != UnityEditor.PrefabType.DisconnectedPrefabInstance &&
                   type != UnityEditor.PrefabType.PrefabInstance;
#endif
        return(isPrefab);
    }
Exemple #3
0
        protected override void OnValidate()
        {
            base.OnValidate();

            m_Size = Mathf.Clamp01(m_Size);

            //This can be invoked before OnEnabled is called. So we shouldn't be accessing other objects, before OnEnable is called.
            if (IsActive())
            {
                UpdateCachedReferences();
                Set(m_Value, false);
                // Update rects since other things might affect them even if value didn't change.
                UpdateVisuals();
            }

            UnityEditor.PrefabType prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);
            if (prefabType != UnityEditor.PrefabType.Prefab && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
Exemple #4
0
        bool UnshareNavMeshAsset()
        {
            // Nothing to unshare
            if (m_NavMeshData == null)
            {
                return(false);
            }

            // Prefab parent owns the asset reference
            UnityEditor.PrefabType prefabType = UnityEditor.PrefabUtility.GetPrefabType(this);
            if (prefabType == UnityEditor.PrefabType.Prefab)
            {
                return(false);
            }

            // An instance can share asset reference only with its prefab parent
            var prefab = UnityEditor.PrefabUtility.GetPrefabParent(this) as NavMeshSurface;

            if (prefab != null && prefab.navMeshData == navMeshData)
            {
                return(false);
            }

            // Don't allow referencing an asset that's assigned to another surface
            for (var i = 0; i < s_NavMeshSurfaces.Count; ++i)
            {
                var surface = s_NavMeshSurfaces[i];
                if (surface != this && surface.m_NavMeshData == m_NavMeshData)
                {
                    return(true);
                }
            }

            // Asset is not referenced by known surfaces
            return(false);
        }
    public static bool doCombinedValidate(MB2_MeshBakerRoot mom, MB_ObjsToCombineTypes objToCombineType)
    {
//		MB2_MeshBaker mom = (MB2_MeshBaker) target;

        if (mom.textureBakeResults == null)
        {
            Debug.LogError("Need to set textureBakeResults");
            return(false);
        }
        if (!(mom is MB2_TextureBaker))
        {
            MB2_TextureBaker tb = mom.GetComponent <MB2_TextureBaker>();
            if (tb != null && tb.textureBakeResults != mom.textureBakeResults)
            {
                Debug.LogWarning("textureBakeResults on this component is not the same as the textureBakeResults on the MB2_TextureBaker.");
            }
        }

        List <UnityEngine.GameObject> objsToMesh = mom.GetObjectsToCombine();

        for (int i = 0; i < objsToMesh.Count; i++)
        {
            UnityEngine.GameObject go = objsToMesh[i];
            if (go == null)
            {
                Debug.LogError("The list of objects to combine contains a null at position." + i + " Select and use [shift] delete to remove");
                return(false);
            }
            for (int j = i + 1; j < objsToMesh.Count; j++)
            {
                if (objsToMesh[i] == objsToMesh[j])
                {
                    Debug.LogError("The list of objects to combine contains duplicates.");
                    return(false);
                }
            }
            if (MB_Utility.GetGOMaterials(go) == null)
            {
                Debug.LogError("UnityEngine.Object " + go + " in the list of objects to be combined does not have a material");
                return(false);
            }
            if (MB_Utility.GetMesh(go) == null)
            {
                Debug.LogError("UnityEngine.Object " + go + " in the list of objects to be combined does not have a mesh");
                return(false);
            }
        }

        if (mom.textureBakeResults.doMultiMaterial)
        {
            if (!validateSubmeshOverlap(mom))             //only warns currently
            {
                return(false);
            }
        }
        List <UnityEngine.GameObject> objs = objsToMesh;

        if (mom is MB2_MeshBaker)
        {
            MB2_TextureBaker tb = mom.GetComponent <MB2_TextureBaker>();
            if (((MB2_MeshBaker)mom).useObjsToMeshFromTexBaker && tb != null)
            {
                objs = tb.objsToMesh;
            }
            if (objs == null || objs.Count == 0)
            {
                Debug.LogError("No meshes to combine. Please assign some meshes to combine.");
                return(false);
            }
        }

#if UNITY_EDITOR
        for (int i = 0; i < objsToMesh.Count; i++)
        {
            UnityEditor.PrefabType pt = UnityEditor.PrefabUtility.GetPrefabType(objsToMesh[i]);
            if (pt == UnityEditor.PrefabType.None ||
                pt == UnityEditor.PrefabType.PrefabInstance ||
                pt == UnityEditor.PrefabType.ModelPrefabInstance ||
                pt == UnityEditor.PrefabType.DisconnectedPrefabInstance ||
                pt == UnityEditor.PrefabType.DisconnectedModelPrefabInstance)
            {
                // these are scene objects
                if (objToCombineType == MB_ObjsToCombineTypes.prefabOnly)
                {
                    Debug.LogWarning("The list of objects to combine contains scene objects. You probably want prefabs." + objsToMesh[i] + " is a scene object");
                }
            }
            else if (objToCombineType == MB_ObjsToCombineTypes.sceneObjOnly)
            {
                //these are prefabs
                Debug.LogWarning("The list of objects to combine contains prefab objects. You probably want scene objects." + objsToMesh[i] + " is a prefab object");
            }
        }
#endif
        return(true);
    }