CheckNullArgument() private static method

private static CheckNullArgument ( System arg, string message ) : void
arg System
message string
return void
コード例 #1
0
 public static Object Instantiate(Object original, Transform parent, bool worldPositionStays)
 {
     if (parent == null)
     {
         return(Object.Internal_CloneSingle(original));
     }
     Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
     return(Object.Internal_CloneSingleWithParent(original, parent, worldPositionStays));
 }
コード例 #2
0
 public static Object Instantiate(Object original, Vector3 position, Quaternion rotation, Transform parent)
 {
     if (parent == null)
     {
         return(Object.Internal_InstantiateSingle(original, position, rotation));
     }
     Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
     return(Object.Internal_InstantiateSingleWithParent(original, parent, position, rotation));
 }
コード例 #3
0
 public static Object Instantiate(Object original, Vector3 position, Quaternion rotation)
 {
     Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
     if (original is ScriptableObject)
     {
         throw new ArgumentException("Cannot instantiate a ScriptableObject with a position and rotation");
     }
     return(Object.Internal_InstantiateSingle(original, position, rotation));
 }
コード例 #4
0
        public static T Instantiate <T>(T original) where T : Object
        {
            Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
            T    t    = (T)((object)Object.Internal_CloneSingle(original));
            bool flag = t == null;

            if (flag)
            {
                throw new UnityException("Instantiate failed because the clone was destroyed during creation. This can happen if DestroyImmediate is called in MonoBehaviour.Awake.");
            }
            return(t);
        }
コード例 #5
0
        public static Object Instantiate(Object original)
        {
            Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
            Object @object = Object.Internal_CloneSingle(original);
            bool   flag    = @object == null;

            if (flag)
            {
                throw new UnityException("Instantiate failed because the clone was destroyed during creation. This can happen if DestroyImmediate is called in MonoBehaviour.Awake.");
            }
            return(@object);
        }
コード例 #6
0
        public static Object Instantiate(Object original, Transform parent, bool instantiateInWorldSpace)
        {
            Object result;

            if (parent == null)
            {
                result = Object.Internal_CloneSingle(original);
            }
            else
            {
                Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
                result = Object.Internal_CloneSingleWithParent(original, parent, instantiateInWorldSpace);
            }
            return(result);
        }
コード例 #7
0
ファイル: Object.cs プロジェクト: cogspace/UmaInGodot-Poc
        public static Object Instantiate(Object original, Transform parent, bool instantiateInWorldSpace)
        {
            if ((Object)parent == (Object)null)
            {
                return(Object.Instantiate(original));
            }
            Object.CheckNullArgument((object)original, "The Object you want to instantiate is null.");
            Object @object = Object.Internal_CloneSingleWithParent(original, parent, instantiateInWorldSpace);

            if (@object == (Object)null)
            {
                throw new Exception("Instantiate failed because the clone was destroyed during creation. This can happen if DestroyImmediate is called in MonoBehaviour.Awake.");
            }
            return(@object);
        }
コード例 #8
0
ファイル: Object.cs プロジェクト: sunl4nl/NC_TreeServer
        // public int GetInstanceID()
        // {
        //     return this.m_InstanceID;
        // }

//        public override bool Equals(object o)
//        {
//            return Object.CompareBaseObjects(this, o as Object);
//        }

        // private static bool CompareBaseObjects(Object lhs, Object rhs)
        // {
        //     return lhs == rhs;
//            if (lhs == null && rhs == null)
//                return true;
//            if (lhs != null && rhs != null)
//                return lhs.m_InstanceID == rhs.m_InstanceID;
//
//            return false;
        // }



//        public static T DeepClone<T>(T obj)
//        {
//            using (var ms = new MemoryStream())
//            {
//                var formatter = new BinaryFormatter();
//                formatter.Serialize(ms, obj);
//                ms.Position = 0;
//
//                return (T) formatter.Deserialize(ms);
//            }
//        }

        public static Object Instantiate(Object original)
        {
            Object.CheckNullArgument((object)original, "The Object you want to instantiate is null.");

            var gameObject = original as GameObject;

            if (gameObject != null)
            {
                SceneManager.dontAddGameObject = true;
            }

            //var serializer = UnikonEngine.serializationContext.GetSerializer(original.GetType());
            //MessagePackObject mpo = serializer.ToMessagePackObject(original);
            //var clone = serializer.FromMessagePackObject(mpo);

            if (gameObject != null)
            {
#if DEBUG_UNIKON
                Debug.Log("GameObject Instantiate");
                Debug.Log(mpo.ToString());


                foreach (var component in (clone as GameObject).components)
                {
                    Debug.Log(component.GetType().Name);
                }
#endif

                //SceneManager.dontAddGameObject = false;
                //SceneManager.AddGameObject(clone as GameObject);

//                gameObject.dontAwake = false;
//                foreach (var component in gameObject.components)
//                {
//                    var awakeMethod = component.GetType().GetMethod("Awake",
//                        BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
//                    if (awakeMethod != null)
//                    {
//                        Debug.Log("Invoke Awake " + component.GetType());
//                        awakeMethod.Invoke(component, BindingFlags.InvokeMethod, null, null, CultureInfo.CurrentCulture);
//                    }
//
//                }
            }
            //return (Object) clone;
            return(null);
        }
コード例 #9
0
        public static Object Instantiate(Object original, Vector3 position, Quaternion rotation)
        {
            Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
            bool flag = original is ScriptableObject;

            if (flag)
            {
                throw new ArgumentException("Cannot instantiate a ScriptableObject with a position and rotation");
            }
            Object @object = Object.Internal_InstantiateSingle(original, position, rotation);
            bool   flag2   = @object == null;

            if (flag2)
            {
                throw new UnityException("Instantiate failed because the clone was destroyed during creation. This can happen if DestroyImmediate is called in MonoBehaviour.Awake.");
            }
            return(@object);
        }
コード例 #10
0
        public static Object Instantiate(Object original, Transform parent, bool instantiateInWorldSpace)
        {
            bool   flag = parent == null;
            Object result;

            if (flag)
            {
                result = Object.Instantiate(original);
            }
            else
            {
                Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
                Object @object = Object.Internal_CloneSingleWithParent(original, parent, instantiateInWorldSpace);
                bool   flag2   = @object == null;
                if (flag2)
                {
                    throw new UnityException("Instantiate failed because the clone was destroyed during creation. This can happen if DestroyImmediate is called in MonoBehaviour.Awake.");
                }
                result = @object;
            }
            return(result);
        }
コード例 #11
0
 public static T Instantiate <T>(T original) where T : Object
 {
     Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
     return((T)((object)Object.Internal_CloneSingle(original)));
 }
コード例 #12
0
 public static Object Instantiate(Object original)
 {
     Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
     return(Object.Internal_CloneSingle(original));
 }
コード例 #13
0
 public static Object Instantiate(Object original, Vector3 position, Quaternion rotation)
 {
     Object.CheckNullArgument(original, "The Object you want to instantiate is null.");
     return(Object.Internal_InstantiateSingle(original, position, rotation));
 }