architecture – Instantiating GameObjects in Custom Game Engine

So,i’m having a bit of an issue with instantiating my gameobjects into to universe(My Scene object).

I can create an empty object from scratch and populate it from there with ease,my problem starts when i try to clone the gameobject which i just created.

My steps are

  1. I create an empty gameobject (GAMEOBJECT A)
  2. I add an component to it (COMPONENT A)
  3. Now i create a gameobject B from A
  4. GameObject B created,and the component A is in the component list of the gameobject B
  5. I try to get the component using inheritance but nullptr returns

It seems when i try to clone components,it returns only the base class pointer.There i try to recreate the derived class and add it to new gameobject’s component list but obviously i fail.

  • If i cant solve this with inheritance how can i solve it ?
  • is there better way to implement such a desing ?
  • or i just fail to use inheritance in c++.If it’s, can you guys point out what am i doing wrong here

This is my GameObject AKA RGameElement

enter image description here

This is my Component AKA RElementComponent

enter image description here

and this my Instantiate via gameobject ref function

enter image description here

unity – Instantiating only 1 Prefab at a time with a counter in the Update Function

I have a hard time getting the timer to work properly and then instantiating for x seconds at a time.
My problem with my script is that Prefab installs as unlimited and doesn't stop after instantiating. The second problem is that _spawnTime is not equal to _resetTime, so it might start again after reaching 0.
I came up with this script so far:


{
(Header("Spawn Object"))
public GameObject _SplatterRock;
public GameObject IvanChar;
(Space)
(Header("Spawn Position"))
public Vector3 _spawnPosition;
(Header("Spawn Options"))
public float _spawnTime = 2f;
public float _resetTime = 0f;
public bool _stopSpawning = false;

private void Update()
{
    if(_spawnTime >= _resetTime)
    {
        _spawnTime -= Time.deltaTime;

        if (_spawnTime <= 0f && !_stopSpawning)
        {
            _spawnTime = _resetTime;
            GameObject _spawnedSplatterRocks = Instantiate(_SplatterRock, _spawnPosition, Quaternion.identity) as GameObject;
            _stopSpawning = false;
        }
    }
}

unit: problem with instantiating buttons and variables in Unity3D

I'm currently trying to make a system where a button inventory is created and at runtime the buttons are placed in a GUI component (Panel). I used a button list that is created at startup and creates X number of buttons for X number of spells found for that player, and for some reason the created button doesn't recognize any changes made to it:

    public void createButton(int index)
    {
        var panel = GameObject.Find("ButtonPanel");
        Spell spell = GlobalControl.Instance.spells(index);
        GameObject button1 = (GameObject)Instantiate(ButtonPrefab);
        button1.GetComponent().text = spell.spellname;
        button1.GetComponent().SetParent(panel.transform);
        //get prev button position
        float yindex = 130.0f - spellinv.Count * 35.0f;
        button1.GetComponent().SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, yindex + 0, 10);
        button1.layer = 5;
        spellinv.Add(button1);
    }

There are no runtime issues, however RectTransform does not alter the position it is in (0,0,0), and the text is still set to the prefabricated default "Button", it seems to register nothing that applies to the button, except for the layer settings.

c # – Instantiating ViewModels with Caliburn Micro

I am using WPF (MVVM), Caliburn Micro and Autofac to create a simple desktop application. I am a beginner in all three.

I have a ShellView with a ContentControl (obligated to CurrentView) which shows the DetailsView after clicking a button (linked to ShowDetails())

    internal class ShellViewModel : BaseViewModel
    {
        private BaseViewModel _currentView;
        private BaseViewModel _detailsView;
        public PersonModel Person { get; private set; }

        public BaseViewModel CurrentView
        {
            get => _currentView; set
            {
                _currentView = value;
                NotifyOfPropertyChange(() => CurrentView);
            }
        }

        public CreateNewShellViewModel(IMessageBoxService messageServce, IEventAggregator events, IWindowManager windowManager) : base(messageServce, events, windowManager)
        {
            Person = IoC.Get();
            _detailsView = IoC.Get();
            (DetailsViewModel)_detailsView.Person = Person; //is there a better way of doing this?
        }

        public void ShowDetails()
        {
            CurrentView = _detailsView;
        }        
    }

    internal class DetailsViewModel : BaseViewModel
    {
        public PersonModel Person { get; set; }

        public DetailsViewModel(IMessageBoxService messageServce, IEventAggregator events, IWindowManager windowManager) : base(messageServce, events, windowManager)
        {

        }

        //other methods go here
    }

I am using Caliburn Micro & # 39; s IoC.Get to get the PersonModel Y _detailsViewIs this the right way to do this?

I also want to pass the same instance of Person from ShellViewModel to DetailsViewModel. For a while I was doing things manually:

 _detailsView = new DetailsViewModel(MessageService, Events, WindowManager, Person);

So I thought it was easier to grab a DetailsViewModel and simply set the Person property, but I can't seem to find anyone else doing this:

_detailsView = IoC.Get();
(DetailsViewModel)_detailsView.Person = Person;

Are any of these approaches correct? What would you do different?

Thank you

unity: GameObject not destroyed in ExecuteInEditMode and Spooky Instantiating

I was trying to get acquainted with Unity's. ExecuteInEditMode

Everything is fine, keep the old object, although I have eliminated them.

And one more thing, even though everything (the cube) is created an instance is set as a secondary element of the GameObject script, where do the other cubes come from?

I have this code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
Public class Road: MonoBehaviour
{
Public list points = new list();
Public list gameObjects = new list();
private int account = 0;
void Home ()
{}
Null update ()
{
yes (account! = points. Account)
{
account = points. Account;
foreach (GameObject g in gameObjects)
{
DestroyImmediate (g);
}
gameObjects.Clear ();
int i = 0;
foreach (Vector3 point in points)
{
Debug.Log (++ i + "" + point);
GameObject tem = Instantiate (GameObject.CreatePrimitive (PrimitiveType.Cube), point, Quaternion.identity);
tem.transform.parent = gameObject.transform;
gameObjects.Add (tem);
}
}
}
}

Here is a supplement:

enter the description of the image here