示例#1
0
        public override bool EDITOR_CanAdd(Object asset)
        {
            UnityEditor.PrefabAssetType prefabType = UnityEditor.PrefabUtility.GetPrefabAssetType(asset);
            bool rightType = prefabType == UnityEditor.PrefabAssetType.Regular || prefabType == UnityEditor.PrefabAssetType.Variant;

            return(rightType && base.EDITOR_CanAdd(asset));
        }
示例#2
0
        protected override void OnValidate()
        {
            base.OnValidate();
            Set(m_IsOn, false);
            PlayEffect(toggleTransition == ToggleTransition.None);

            UnityEditor.PrefabAssetType prefabType = UnityEditor.PrefabUtility.GetPrefabAssetType(this);
            if (prefabType != UnityEditor.PrefabAssetType.Regular && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }
        public static bool IsPrefab(this GameObject go)
        {
            if (go == null)
            {
                return(false);
            }

            if (Application.isEditor && !Application.isPlaying)
            {
                #if UNITY_EDITOR
                UnityEditor.PrefabAssetType assetType = UnityEditor.PrefabUtility.GetPrefabAssetType(go);
                return(assetType == UnityEditor.PrefabAssetType.Regular || assetType == UnityEditor.PrefabAssetType.Model);
                #else
                throw new System.InvalidOperationException("Does not work in edit mode");
                #endif
            }
            return(go.scene.buildIndex < 0 && go.scene.path == null);
        }
示例#4
0
        protected override void OnValidate()
        {
            base.OnValidate();

            if (WholeNumbers)
            {
                m_MinValue = Mathf.Round(m_MinValue);
                m_MaxValue = Mathf.Round(m_MaxValue);
            }
            UpdateCachedReferences();
            SetX(m_ValueX, false);
            SetY(m_ValueY, false);
            // Update rects since other things might affect them even if value didn't change.
            UpdateVisuals();

            UnityEditor.PrefabAssetType prefabType = UnityEditor.PrefabUtility.GetPrefabAssetType(this);
            if (prefabType != UnityEditor.PrefabAssetType.Regular && !Application.isPlaying)
            {
                CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
            }
        }